33a566386c669596d45c8e643fa38b99206f6c8c
[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   "fsck",
83   "get-append",
84   "get-autosync",
85   "get-e2label",
86   "get-e2uuid",
87   "get-path",
88   "get-qemu",
89   "get-state",
90   "get-verbose",
91   "grub-install",
92   "hexdump",
93   "is-busy",
94   "is-config",
95   "is-dir",
96   "is-file",
97   "is-launching",
98   "is-ready",
99   "kill-subprocess",
100   "launch",
101   "list-devices",
102   "list-partitions",
103   "ll",
104   "ls",
105   "lstat",
106   "lvcreate",
107   "lvm-remove-all",
108   "lvremove",
109   "lvresize",
110   "lvs",
111   "lvs-full",
112   "mkdir",
113   "mkdir-p",
114   "mkfs",
115   "mount",
116   "mount-options",
117   "mount-ro",
118   "mount-vfs",
119   "mounts",
120   "mv",
121   "path",
122   "ping-daemon",
123   "pvcreate",
124   "pvremove",
125   "pvresize",
126   "pvs",
127   "pvs-full",
128   "qemu",
129   "read-lines",
130   "resize2fs",
131   "rm",
132   "rm-rf",
133   "rmdir",
134   "run",
135   "set-append",
136   "set-autosync",
137   "set-e2label",
138   "set-e2uuid",
139   "set-path",
140   "set-qemu",
141   "set-verbose",
142   "sfdisk",
143   "sfdisk-N",
144   "sfdisk-disk-geometry",
145   "sfdisk-kernel-geometry",
146   "sfdisk-l",
147   "stat",
148   "statvfs",
149   "strings",
150   "strings-e",
151   "sync",
152   "tar-in",
153   "tar-out",
154   "tgz-in",
155   "tgz-out",
156   "touch",
157   "tune2fs-l",
158   "umount",
159   "umount-all",
160   "unmount",
161   "unmount-all",
162   "upload",
163   "verbose",
164   "vg-activate",
165   "vg-activate-all",
166   "vgcreate",
167   "vgremove",
168   "vgs",
169   "vgs-full",
170   "write-file",
171   "zero",
172   "zerofree",
173   NULL
174 };
175
176 static char *
177 generator (const char *text, int state)
178 {
179   static int index, len;
180   const char *name;
181
182   if (!state) {
183     index = 0;
184     len = strlen (text);
185   }
186
187   while ((name = commands[index]) != NULL) {
188     index++;
189     if (strncasecmp (name, text, len) == 0)
190       return strdup (name);
191   }
192
193   return NULL;
194 }
195
196 #endif /* HAVE_LIBREADLINE */
197
198 char **do_completion (const char *text, int start, int end)
199 {
200   char **matches = NULL;
201
202 #ifdef HAVE_LIBREADLINE
203   if (start == 0)
204     matches = rl_completion_matches (text, generator);
205 #endif
206
207   return matches;
208 }