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