Fix dependencies in perl so it doesn't always rebuild
[libguestfs.git] / fish / completion.c
index 9318288..92843e5 100644 (file)
 #ifdef HAVE_LIBREADLINE
 
 static const char *const commands[] = {
+  BUILTIN_COMMANDS_FOR_COMPLETION,
+  "launch",
+  "run",
+  "kill-subprocess",
+  "add-drive",
   "add",
   "add-cdrom",
-  "add-drive",
-  "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",
+  "add-drive-ro",
+  "add-ro",
   "config",
-  "cp",
-  "cp-a",
-  "debug",
-  "dmesg",
-  "download",
-  "drop-caches",
-  "equal",
-  "exists",
-  "file",
-  "fsck",
-  "get-autosync",
-  "get-e2label",
-  "get-e2uuid",
-  "get-path",
+  "set-qemu",
+  "qemu",
   "get-qemu",
-  "get-state",
+  "set-path",
+  "path",
+  "get-path",
+  "set-append",
+  "append",
+  "get-append",
+  "set-autosync",
+  "autosync",
+  "get-autosync",
+  "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",
-  "lvs",
-  "lvs-full",
-  "mkdir",
-  "mkdir-p",
-  "mkfs",
-  "mount",
-  "mount-options",
-  "mount-ro",
-  "mount-vfs",
-  "mounts",
-  "mv",
-  "path",
-  "ping-daemon",
-  "pvcreate",
-  "pvremove",
+  "list-devices",
+  "list-partitions",
   "pvs",
+  "vgs",
+  "lvs",
   "pvs-full",
-  "qemu",
+  "vgs-full",
+  "lvs-full",
   "read-lines",
+  "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-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",
+  "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",
-  "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",
+  "sleep",
+  "ntfs-3g-probe",
+  "sh",
+  "sh-lines",
+  "glob-expand",
+  "scrub-device",
+  "scrub-file",
+  "scrub-freespace",
   NULL
 };
 
@@ -171,6 +197,8 @@ generator (const char *text, int state)
     len = strlen (text);
   }
 
+  rl_attempted_completion_over = 1;
+
   while ((name = commands[index]) != NULL) {
     index++;
     if (strncasecmp (name, text, len) == 0)
@@ -187,8 +215,12 @@ char **do_completion (const char *text, int start, int end)
   char **matches = NULL;
 
 #ifdef HAVE_LIBREADLINE
+  rl_completion_append_character = ' ';
+
   if (start == 0)
     matches = rl_completion_matches (text, generator);
+  else if (complete_dest_paths)
+    matches = rl_completion_matches (text, complete_dest_paths_generator);
 #endif
 
   return matches;