]> xenbits.xensource.com Git - libvirt.git/commitdiff
vshCmddefCheckInternals: Fix listing of missing completers for 'VSH_OT_ARGV'
authorPeter Krempa <pkrempa@redhat.com>
Fri, 1 Mar 2024 11:35:46 +0000 (12:35 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Mar 2024 14:02:51 +0000 (15:02 +0100)
Use a switch statement to cover all cases and check for missing
completers for arguments declared as VSH_OT_ARGV.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/vsh.c

index 63424fcf8fad04831113a162f51edc65fae5187c..4f98f563f3bb7c5cdb150c3ed7976e70cb7b8062 100644 (file)
@@ -324,10 +324,24 @@ vshCmddefCheckInternals(vshControl *ctl,
             return -1; /* too many options */
         }
 
-        if (missingCompleters &&
-            (opt->type == VSH_OT_STRING || opt->type == VSH_OT_DATA) &&
-            !opt->completer)
-            virBufferStrcat(&complbuf, opt->name, ", ", NULL);
+        if (missingCompleters && !opt->completer) {
+            switch (opt->type) {
+            case VSH_OT_STRING:
+            case VSH_OT_DATA:
+            case VSH_OT_ARGV:
+                virBufferStrcat(&complbuf, opt->name, ", ", NULL);
+                break;
+
+            case VSH_OT_BOOL:
+                /* only name is completed */
+            case VSH_OT_INT:
+                /* no point in completing numbers */
+            case VSH_OT_ALIAS:
+                /* alias is handled in the referenced command */
+            case VSH_OT_NONE:
+                break;
+            }
+        }
 
         switch (opt->type) {
         case VSH_OT_NONE: