]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: Require that positional non-argv arguments are required
authorPeter Krempa <pkrempa@redhat.com>
Tue, 5 Mar 2024 15:17:21 +0000 (16:17 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Mar 2024 14:02:52 +0000 (15:02 +0100)
This is logically enforced by existing checks, thus we can formalize it.

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

index 33a9dcdfe87ad5d9de9496f99b467a1cb421472e..ef6451f70e87ff0a5aa7d7711b4fdf0accd19614 100644 (file)
@@ -329,6 +329,13 @@ vshCmddefCheckInternals(vshControl *ctl,
             }
         }
 
+        /* require that positional non-argv options are required */
+        if (opt->positional && !opt->required && opt->type != VSH_OT_ARGV) {
+            vshError(ctl, "positional argument '%s' of command '%s' must be required",
+                     opt->name, cmd->name);
+            return -1;
+        }
+
         switch (opt->type) {
         case VSH_OT_NONE:
             vshError(ctl, "invalid type 'NONE' of option '%s' of command '%s'",