cc9991feb79946ba28353de47aa8ab9fb0fa3d4f
[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   "debug",
73   "download",
74   "exists",
75   "file",
76   "fsck",
77   "get-autosync",
78   "get-e2label",
79   "get-e2uuid",
80   "get-path",
81   "get-qemu",
82   "get-state",
83   "get-verbose",
84   "is-busy",
85   "is-config",
86   "is-dir",
87   "is-file",
88   "is-launching",
89   "is-ready",
90   "kill-subprocess",
91   "launch",
92   "list-devices",
93   "list-partitions",
94   "ll",
95   "ls",
96   "lstat",
97   "lvcreate",
98   "lvm-remove-all",
99   "lvremove",
100   "lvs",
101   "lvs-full",
102   "mkdir",
103   "mkdir-p",
104   "mkfs",
105   "mount",
106   "mount-options",
107   "mount-ro",
108   "mount-vfs",
109   "mounts",
110   "path",
111   "pvcreate",
112   "pvremove",
113   "pvs",
114   "pvs-full",
115   "qemu",
116   "read-lines",
117   "rm",
118   "rm-rf",
119   "rmdir",
120   "run",
121   "set-autosync",
122   "set-e2label",
123   "set-e2uuid",
124   "set-path",
125   "set-qemu",
126   "set-verbose",
127   "sfdisk",
128   "stat",
129   "statvfs",
130   "sync",
131   "tar-in",
132   "tar-out",
133   "tgz-in",
134   "tgz-out",
135   "touch",
136   "tune2fs-l",
137   "umount",
138   "umount-all",
139   "unmount",
140   "unmount-all",
141   "upload",
142   "verbose",
143   "vgcreate",
144   "vgremove",
145   "vgs",
146   "vgs-full",
147   "write-file",
148   "zero",
149   NULL
150 };
151
152 static char *
153 generator (const char *text, int state)
154 {
155   static int index, len;
156   const char *name;
157
158   if (!state) {
159     index = 0;
160     len = strlen (text);
161   }
162
163   while ((name = commands[index]) != NULL) {
164     index++;
165     if (strncasecmp (name, text, len) == 0)
166       return strdup (name);
167   }
168
169   return NULL;
170 }
171
172 #endif /* HAVE_LIBREADLINE */
173
174 char **do_completion (const char *text, int start, int end)
175 {
176   char **matches = NULL;
177
178 #ifdef HAVE_LIBREADLINE
179   if (start == 0)
180     matches = rl_completion_matches (text, generator);
181 #endif
182
183   return matches;
184 }