d0e8050afc592d25e4bd5aeb3f076882fcd4a684
[libguestfs.git] / fish / completion.c
1 /* libguestfs generated file
2  * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3  * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
4  *
5  * Copyright (C) 2009 Red Hat Inc.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include <config.h>
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 #ifdef HAVE_LIBREADLINE
29 #include <readline/readline.h>
30 #endif
31
32 #include "fish.h"
33
34 #ifdef HAVE_LIBREADLINE
35
36 static const char *const commands[] = {
37   "add",
38   "add-cdrom",
39   "add-drive",
40   "append",
41   "aug-close",
42   "aug-defnode",
43   "aug-defvar",
44   "aug-get",
45   "aug-init",
46   "aug-insert",
47   "aug-load",
48   "aug-ls",
49   "aug-match",
50   "aug-mv",
51   "aug-rm",
52   "aug-save",
53   "aug-set",
54   "autosync",
55   "blockdev-flushbufs",
56   "blockdev-getbsz",
57   "blockdev-getro",
58   "blockdev-getsize64",
59   "blockdev-getss",
60   "blockdev-getsz",
61   "blockdev-rereadpt",
62   "blockdev-setbsz",
63   "blockdev-setro",
64   "blockdev-setrw",
65   "cat",
66   "cdrom",
67   "checksum",
68   "chmod",
69   "chown",
70   "command",
71   "command-lines",
72   "config",
73   "cp",
74   "cp-a",
75   "debug",
76   "dmesg",
77   "download",
78   "drop-caches",
79   "equal",
80   "exists",
81   "file",
82   "find",
83   "fsck",
84   "get-append",
85   "get-autosync",
86   "get-e2label",
87   "get-e2uuid",
88   "get-path",
89   "get-qemu",
90   "get-state",
91   "get-verbose",
92   "grub-install",
93   "hexdump",
94   "is-busy",
95   "is-config",
96   "is-dir",
97   "is-file",
98   "is-launching",
99   "is-ready",
100   "kill-subprocess",
101   "launch",
102   "list-devices",
103   "list-partitions",
104   "ll",
105   "ls",
106   "lstat",
107   "lvcreate",
108   "lvm-remove-all",
109   "lvremove",
110   "lvresize",
111   "lvs",
112   "lvs-full",
113   "mkdir",
114   "mkdir-p",
115   "mkfs",
116   "mount",
117   "mount-options",
118   "mount-ro",
119   "mount-vfs",
120   "mounts",
121   "mv",
122   "path",
123   "ping-daemon",
124   "pvcreate",
125   "pvremove",
126   "pvresize",
127   "pvs",
128   "pvs-full",
129   "qemu",
130   "read-lines",
131   "resize2fs",
132   "rm",
133   "rm-rf",
134   "rmdir",
135   "run",
136   "set-append",
137   "set-autosync",
138   "set-e2label",
139   "set-e2uuid",
140   "set-path",
141   "set-qemu",
142   "set-verbose",
143   "sfdisk",
144   "sfdisk-N",
145   "sfdisk-disk-geometry",
146   "sfdisk-kernel-geometry",
147   "sfdisk-l",
148   "stat",
149   "statvfs",
150   "strings",
151   "strings-e",
152   "sync",
153   "tar-in",
154   "tar-out",
155   "tgz-in",
156   "tgz-out",
157   "touch",
158   "tune2fs-l",
159   "umount",
160   "umount-all",
161   "unmount",
162   "unmount-all",
163   "upload",
164   "verbose",
165   "vg-activate",
166   "vg-activate-all",
167   "vgcreate",
168   "vgremove",
169   "vgs",
170   "vgs-full",
171   "write-file",
172   "zero",
173   "zerofree",
174   NULL
175 };
176
177 static char *
178 generator (const char *text, int state)
179 {
180   static int index, len;
181   const char *name;
182
183   if (!state) {
184     index = 0;
185     len = strlen (text);
186   }
187
188   while ((name = commands[index]) != NULL) {
189     index++;
190     if (strncasecmp (name, text, len) == 0)
191       return strdup (name);
192   }
193
194   return NULL;
195 }
196
197 #endif /* HAVE_LIBREADLINE */
198
199 char **do_completion (const char *text, int start, int end)
200 {
201   char **matches = NULL;
202
203 #ifdef HAVE_LIBREADLINE
204   if (start == 0)
205     matches = rl_completion_matches (text, generator);
206 #endif
207
208   return matches;
209 }