summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-05-27 12:29:35 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-05-27 12:29:35 +0100
commit6610af333b93d93f6f0f4b917e0caee0d35ba389 (patch)
treee2a9fdfe53d2a737a426b1965fbf7e3fe3245b59
parent65ad55778b8cd8e948d59fd3624966018366c45f (diff)
downloadlibguestfs-6610af333b93d93f6f0f4b917e0caee0d35ba389.tar.gz
libguestfs-6610af333b93d93f6f0f4b917e0caee0d35ba389.tar.xz
libguestfs-6610af333b93d93f6f0f4b917e0caee0d35ba389.zip
Guestfish built-in commands auto-complete (RHBZ#501878).
-rw-r--r--fish/completion.c225
-rw-r--r--fish/fish.h10
-rwxr-xr-xsrc/generator.ml6
3 files changed, 127 insertions, 114 deletions
diff --git a/fish/completion.c b/fish/completion.c
index ec582963..305e810c 100644
--- a/fish/completion.c
+++ b/fish/completion.c
@@ -34,144 +34,145 @@
#ifdef HAVE_LIBREADLINE
static const char *const commands[] = {
+ BUILTIN_COMMANDS_FOR_COMPLETION,
+ "launch",
+ "run",
+ "kill-subprocess",
+ "add-drive",
"add",
"add-cdrom",
- "add-drive",
- "append",
- "aug-close",
- "aug-defnode",
- "aug-defvar",
- "aug-get",
- "aug-init",
- "aug-insert",
- "aug-load",
- "aug-ls",
- "aug-match",
- "aug-mv",
- "aug-rm",
- "aug-save",
- "aug-set",
- "autosync",
- "blockdev-flushbufs",
- "blockdev-getbsz",
- "blockdev-getro",
- "blockdev-getsize64",
- "blockdev-getss",
- "blockdev-getsz",
- "blockdev-rereadpt",
- "blockdev-setbsz",
- "blockdev-setro",
- "blockdev-setrw",
- "cat",
"cdrom",
- "checksum",
- "chmod",
- "chown",
- "command",
- "command-lines",
"config",
- "cp",
- "cp-a",
- "debug",
- "dmesg",
- "download",
- "drop-caches",
- "e2fsck-f",
- "equal",
- "exists",
- "file",
- "find",
- "fsck",
+ "set-qemu",
+ "qemu",
+ "get-qemu",
+ "set-path",
+ "path",
+ "get-path",
+ "set-append",
+ "append",
"get-append",
+ "set-autosync",
+ "autosync",
"get-autosync",
- "get-e2label",
- "get-e2uuid",
- "get-path",
- "get-qemu",
- "get-state",
+ "set-verbose",
+ "verbose",
"get-verbose",
- "grub-install",
- "hexdump",
- "is-busy",
+ "is-ready",
"is-config",
- "is-dir",
- "is-file",
"is-launching",
- "is-ready",
- "kill-subprocess",
- "launch",
- "list-devices",
- "list-partitions",
+ "is-busy",
+ "get-state",
+ "mount",
+ "sync",
+ "touch",
+ "cat",
"ll",
"ls",
- "lstat",
- "lvcreate",
- "lvm-remove-all",
- "lvremove",
- "lvresize",
- "lvs",
- "lvs-full",
- "mkdir",
- "mkdir-p",
- "mkfs",
- "mount",
- "mount-options",
- "mount-ro",
- "mount-vfs",
- "mounts",
- "mv",
- "path",
- "ping-daemon",
- "pvcreate",
- "pvremove",
- "pvresize",
+ "list-devices",
+ "list-partitions",
"pvs",
+ "vgs",
+ "lvs",
"pvs-full",
- "qemu",
+ "vgs-full",
+ "lvs-full",
"read-lines",
- "resize2fs",
+ "aug-init",
+ "aug-close",
+ "aug-defvar",
+ "aug-defnode",
+ "aug-get",
+ "aug-set",
+ "aug-insert",
+ "aug-rm",
+ "aug-mv",
+ "aug-match",
+ "aug-save",
+ "aug-load",
+ "aug-ls",
"rm",
- "rm-rf",
"rmdir",
- "run",
- "set-append",
- "set-autosync",
- "set-e2label",
- "set-e2uuid",
- "set-path",
- "set-qemu",
- "set-verbose",
+ "rm-rf",
+ "mkdir",
+ "mkdir-p",
+ "chmod",
+ "chown",
+ "exists",
+ "is-file",
+ "is-dir",
+ "pvcreate",
+ "vgcreate",
+ "lvcreate",
+ "mkfs",
"sfdisk",
- "sfdisk-N",
- "sfdisk-disk-geometry",
- "sfdisk-kernel-geometry",
- "sfdisk-l",
+ "write-file",
+ "umount",
+ "unmount",
+ "mounts",
+ "umount-all",
+ "unmount-all",
+ "lvm-remove-all",
+ "file",
+ "command",
+ "command-lines",
"stat",
+ "lstat",
"statvfs",
- "strings",
- "strings-e",
- "sync",
+ "tune2fs-l",
+ "blockdev-setro",
+ "blockdev-setrw",
+ "blockdev-getro",
+ "blockdev-getss",
+ "blockdev-getbsz",
+ "blockdev-setbsz",
+ "blockdev-getsz",
+ "blockdev-getsize64",
+ "blockdev-flushbufs",
+ "blockdev-rereadpt",
+ "upload",
+ "download",
+ "checksum",
"tar-in",
"tar-out",
"tgz-in",
"tgz-out",
- "touch",
- "tune2fs-l",
- "umount",
- "umount-all",
- "unmount",
- "unmount-all",
- "upload",
- "verbose",
- "vg-activate",
- "vg-activate-all",
- "vgcreate",
+ "mount-ro",
+ "mount-options",
+ "mount-vfs",
+ "debug",
+ "lvremove",
"vgremove",
- "vgs",
- "vgs-full",
- "write-file",
+ "pvremove",
+ "set-e2label",
+ "get-e2label",
+ "set-e2uuid",
+ "get-e2uuid",
+ "fsck",
"zero",
+ "grub-install",
+ "cp",
+ "cp-a",
+ "mv",
+ "drop-caches",
+ "dmesg",
+ "ping-daemon",
+ "equal",
+ "strings",
+ "strings-e",
+ "hexdump",
"zerofree",
+ "pvresize",
+ "sfdisk-N",
+ "sfdisk-l",
+ "sfdisk-kernel-geometry",
+ "sfdisk-disk-geometry",
+ "vg-activate-all",
+ "vg-activate",
+ "lvresize",
+ "resize2fs",
+ "find",
+ "e2fsck-f",
NULL
};
diff --git a/fish/fish.h b/fish/fish.h
index 91424e1e..13a2e5c4 100644
--- a/fish/fish.h
+++ b/fish/fish.h
@@ -61,4 +61,14 @@ extern int do_echo (const char *cmd, int argc, char *argv[]);
/* in edit.c */
extern int do_edit (const char *cmd, int argc, char *argv[]);
+/* This should just list all the built-in commands so they can
+ * be added to the generated auto-completion code.
+ */
+#define BUILTIN_COMMANDS_FOR_COMPLETION \
+ "help", \
+ "quit", "exit", "q", \
+ "alloc", "allocate", \
+ "echo", \
+ "edit", "vi", "emacs"
+
#endif /* FISH_H */
diff --git a/src/generator.ml b/src/generator.ml
index 99913a33..9c210bc0 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -4594,9 +4594,12 @@ and generate_fish_completion () =
#ifdef HAVE_LIBREADLINE
static const char *const commands[] = {
+ BUILTIN_COMMANDS_FOR_COMPLETION,
";
- (* Get the commands and sort them, including the aliases. *)
+ (* Get the commands, including the aliases. They don't need to be
+ * sorted - the generator() function just does a dumb linear search.
+ *)
let commands =
List.map (
fun (name, _, _, flags, _, _, _) ->
@@ -4608,7 +4611,6 @@ static const char *const commands[] = {
if name <> alias then [name2; alias] else [name2]
) all_functions in
let commands = List.flatten commands in
- let commands = List.sort compare commands in
List.iter (pr " \"%s\",\n") commands;