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