264c5840dc97ad481b8c67b32df4e0ad9d38fba0
[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   BUILTIN_COMMANDS_FOR_COMPLETION,
38   "launch",
39   "run",
40   "kill-subprocess",
41   "add-drive",
42   "add",
43   "add-cdrom",
44   "cdrom",
45   "add-drive-ro",
46   "add-ro",
47   "config",
48   "set-qemu",
49   "qemu",
50   "get-qemu",
51   "set-path",
52   "path",
53   "get-path",
54   "set-append",
55   "append",
56   "get-append",
57   "set-autosync",
58   "autosync",
59   "get-autosync",
60   "set-verbose",
61   "verbose",
62   "get-verbose",
63   "is-ready",
64   "is-config",
65   "is-launching",
66   "is-busy",
67   "get-state",
68   "mount",
69   "sync",
70   "touch",
71   "cat",
72   "ll",
73   "ls",
74   "list-devices",
75   "list-partitions",
76   "pvs",
77   "vgs",
78   "lvs",
79   "pvs-full",
80   "vgs-full",
81   "lvs-full",
82   "read-lines",
83   "aug-init",
84   "aug-close",
85   "aug-defvar",
86   "aug-defnode",
87   "aug-get",
88   "aug-set",
89   "aug-insert",
90   "aug-rm",
91   "aug-mv",
92   "aug-match",
93   "aug-save",
94   "aug-load",
95   "aug-ls",
96   "rm",
97   "rmdir",
98   "rm-rf",
99   "mkdir",
100   "mkdir-p",
101   "chmod",
102   "chown",
103   "exists",
104   "is-file",
105   "is-dir",
106   "pvcreate",
107   "vgcreate",
108   "lvcreate",
109   "mkfs",
110   "sfdisk",
111   "write-file",
112   "umount",
113   "unmount",
114   "mounts",
115   "umount-all",
116   "unmount-all",
117   "lvm-remove-all",
118   "file",
119   "command",
120   "command-lines",
121   "stat",
122   "lstat",
123   "statvfs",
124   "tune2fs-l",
125   "blockdev-setro",
126   "blockdev-setrw",
127   "blockdev-getro",
128   "blockdev-getss",
129   "blockdev-getbsz",
130   "blockdev-setbsz",
131   "blockdev-getsz",
132   "blockdev-getsize64",
133   "blockdev-flushbufs",
134   "blockdev-rereadpt",
135   "upload",
136   "download",
137   "checksum",
138   "tar-in",
139   "tar-out",
140   "tgz-in",
141   "tgz-out",
142   "mount-ro",
143   "mount-options",
144   "mount-vfs",
145   "debug",
146   "lvremove",
147   "vgremove",
148   "pvremove",
149   "set-e2label",
150   "get-e2label",
151   "set-e2uuid",
152   "get-e2uuid",
153   "fsck",
154   "zero",
155   "grub-install",
156   "cp",
157   "cp-a",
158   "mv",
159   "drop-caches",
160   "dmesg",
161   "ping-daemon",
162   "equal",
163   "strings",
164   "strings-e",
165   "hexdump",
166   "zerofree",
167   "pvresize",
168   "sfdisk-N",
169   "sfdisk-l",
170   "sfdisk-kernel-geometry",
171   "sfdisk-disk-geometry",
172   "vg-activate-all",
173   "vg-activate",
174   "lvresize",
175   "resize2fs",
176   "find",
177   "e2fsck-f",
178   "sleep",
179   "ntfs-3g-probe",
180   NULL
181 };
182
183 static char *
184 generator (const char *text, int state)
185 {
186   static int index, len;
187   const char *name;
188
189   if (!state) {
190     index = 0;
191     len = strlen (text);
192   }
193
194   while ((name = commands[index]) != NULL) {
195     index++;
196     if (strncasecmp (name, text, len) == 0)
197       return strdup (name);
198   }
199
200   return NULL;
201 }
202
203 #endif /* HAVE_LIBREADLINE */
204
205 char **do_completion (const char *text, int start, int end)
206 {
207   char **matches = NULL;
208
209 #ifdef HAVE_LIBREADLINE
210   if (start == 0)
211     matches = rl_completion_matches (text, generator);
212 #endif
213
214   return matches;
215 }