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