virsh: Annotate some optional arguments as positional

Make certain optional arguments truly positional in cases when it makes
semantic sense.

Previously it wasn't possible to have optional positional arguments, but
the parser filled them regardless, thus this preserves functionality.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2024-03-14 17:13:05 +01:00
parent d19b12a681
commit 1304ef40a9
2 changed files with 9 additions and 0 deletions

View File

@ -385,6 +385,7 @@ static const vshCmdOptDef opts_domblkinfo[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "device",
.type = VSH_OT_STRING,
.positional = true,
.completer = virshDomainDiskTargetCompleter,
.help = N_("block device")
},
@ -865,6 +866,7 @@ static const vshCmdOptDef opts_domblkstat[] = {
{.name = "device",
.type = VSH_OT_STRING,
.flags = VSH_OFLAG_EMPTY_OK,
.positional = true,
.completer = virshDomainDiskTargetCompleter,
.help = N_("block device")
},
@ -2219,6 +2221,7 @@ static const vshCmdOptDef opts_domifaddr[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "interface",
.type = VSH_OT_STRING,
.positional = true,
.flags = VSH_OFLAG_NONE,
.completer = virshDomainInterfaceCompleter,
.help = N_("network interface name")},

View File

@ -2939,6 +2939,7 @@ static const vshCmdOptDef opts_blockresize[] = {
},
{.name = "size",
.type = VSH_OT_INT,
.positional = true,
.help = N_("New size of the block device, as scaled integer (default KiB)")
},
{.name = "capacity",
@ -5805,6 +5806,7 @@ static const vshCmdOptDef opts_shutdown[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "mode",
.type = VSH_OT_STRING,
.positional = true,
.completer = virshDomainShutdownModeCompleter,
.help = N_("shutdown mode: acpi|agent|initctl|signal|paravirt")
},
@ -5880,6 +5882,7 @@ static const vshCmdOptDef opts_reboot[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "mode",
.type = VSH_OT_STRING,
.positional = true,
.completer = virshDomainShutdownModeCompleter,
.help = N_("shutdown mode: acpi|agent|initctl|signal|paravirt")
},
@ -11531,6 +11534,7 @@ static const vshCmdOptDef opts_domdisplay[] = {
},
{.name = "type",
.type = VSH_OT_STRING,
.positional = true,
.help = N_("select particular graphical display "
"(e.g. \"vnc\", \"spice\", \"rdp\", \"dbus\")")
},
@ -12675,6 +12679,7 @@ static const vshCmdOptDef opts_change_media[] = {
},
{.name = "source",
.type = VSH_OT_STRING,
.positional = true,
.help = N_("source of the media")
},
{.name = "eject",
@ -13199,6 +13204,7 @@ static const vshCmdOptDef opts_set_user_sshkeys[] = {
},
{.name = "file",
.type = VSH_OT_STRING,
.positional = true,
.completer = virshCompletePathLocalExisting,
.help = N_("optional file to read keys from"),
},