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