5c7f5e014bab83ab50d27e1e8ecd0a7181113355
[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   "lvs",
110   "lvs-full",
111   "mkdir",
112   "mkdir-p",
113   "mkfs",
114   "mount",
115   "mount-options",
116   "mount-ro",
117   "mount-vfs",
118   "mounts",
119   "mv",
120   "path",
121   "ping-daemon",
122   "pvcreate",
123   "pvremove",
124   "pvs",
125   "pvs-full",
126   "qemu",
127   "read-lines",
128   "rm",
129   "rm-rf",
130   "rmdir",
131   "run",
132   "set-append",
133   "set-autosync",
134   "set-e2label",
135   "set-e2uuid",
136   "set-path",
137   "set-qemu",
138   "set-verbose",
139   "sfdisk",
140   "stat",
141   "statvfs",
142   "strings",
143   "strings-e",
144   "sync",
145   "tar-in",
146   "tar-out",
147   "tgz-in",
148   "tgz-out",
149   "touch",
150   "tune2fs-l",
151   "umount",
152   "umount-all",
153   "unmount",
154   "unmount-all",
155   "upload",
156   "verbose",
157   "vgcreate",
158   "vgremove",
159   "vgs",
160   "vgs-full",
161   "write-file",
162   "zero",
163   "zerofree",
164   NULL
165 };
166
167 static char *
168 generator (const char *text, int state)
169 {
170   static int index, len;
171   const char *name;
172
173   if (!state) {
174     index = 0;
175     len = strlen (text);
176   }
177
178   while ((name = commands[index]) != NULL) {
179     index++;
180     if (strncasecmp (name, text, len) == 0)
181       return strdup (name);
182   }
183
184   return NULL;
185 }
186
187 #endif /* HAVE_LIBREADLINE */
188
189 char **do_completion (const char *text, int start, int end)
190 {
191   char **matches = NULL;
192
193 #ifdef HAVE_LIBREADLINE
194   if (start == 0)
195     matches = rl_completion_matches (text, generator);
196 #endif
197
198   return matches;
199 }