[PATCH 08/14] vsh: Add completer for '--command' of 'help' command

Peter Krempa pkrempa at redhat.com
Thu Sep 16 17:10:39 UTC 2021


Wrap 'vshReadlineCommandGenerator' into a function with proper prototype
to provide a completer for the help command.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tools/vsh.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/vsh.c b/tools/vsh.c
index 9c6783dad1..cf24586b25 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3026,9 +3026,20 @@ vshDeinit(vshControl *ctl)
  * Generic commands available to use by any client
  * -----------------------------------------------
  */
+
+static char **
+vshCompleteHelpCommand(vshControl *ctl G_GNUC_UNUSED,
+                       const vshCmd *cmd G_GNUC_UNUSED,
+                       unsigned int completerflags G_GNUC_UNUSED)
+{
+    return vshReadlineCommandGenerator();
+}
+
+
 const vshCmdOptDef opts_help[] = {
     {.name = "command",
      .type = VSH_OT_STRING,
+     .completer = vshCompleteHelpCommand,
      .help = N_("Prints global help, command specific help, or help for a group of related commands")
     },
     {.name = NULL}
-- 
2.31.1




More information about the libvir-list mailing list