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