]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vsh: Make positional parsing of arguments opt-in
authorPeter Krempa <pkrempa@redhat.com>
Tue, 5 Mar 2024 21:37:43 +0000 (22:37 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2024 12:24:30 +0000 (14:24 +0200)
Switch the command parser from using the VSH_OFLAG_REQ_OPT flag
opting out from positional parsing of arguments to a combination of the
'positional' flags for truly positional arguments and
'unwanted_positional' preserving semantics for the existing arguments
where the parser did it due to bad design.

This patch retires VSH_OFLAG_REQ_OPT along with the infrastructure that
was needed to refactor all uses properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 files changed:
tools/virsh-backup.c
tools/virsh-checkpoint.c
tools/virsh-domain-monitor.c
tools/virsh-domain.c
tools/virsh-host.c
tools/virsh-interface.c
tools/virsh-network.c
tools/virsh-nodedev.c
tools/virsh-nwfilter.c
tools/virsh-pool.c
tools/virsh-secret.c
tools/virsh-snapshot.c
tools/virsh-volume.c
tools/virt-admin.c
tools/vsh.c
tools/vsh.h

index 52325b5ca0332a089e2162c1fa5b0d9ee46361d3..9a1e89760f08480a7de14d1e591a1bf39c68216a 100644 (file)
@@ -109,7 +109,6 @@ static const vshCmdOptDef opts_backup_dumpxml[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index 48e3a586e497c01f95a2d92ff815352c4bdff750..e425041ca7a520dd864ee4c2753a809977502141 100644 (file)
@@ -829,7 +829,6 @@ static const vshCmdOptDef opts_checkpoint_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index d88cf64235e1c73d86a80176836677802261fb1c..5531d3b737b7e9314215c2d3c5cd9f3768076faf 100644 (file)
@@ -277,7 +277,6 @@ static const vshCmdOptDef opts_dommemstat[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "period",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("period in seconds to set collection")
     },
     VIRSH_COMMON_OPT_CONFIG(N_("affect next boot")),
index 600388dceb4954e311e74be33c34474a701e4449..91a9dfd96a385a3e8ad13a31dcb1ce66d326ab65 100644 (file)
@@ -434,38 +434,31 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     {.name = "targetbus",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("target bus of disk device")
     },
     {.name = "driver",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("driver of disk device")
     },
     {.name = "subdriver",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("subdriver of disk device")
     },
     {.name = "iothread",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshDomainIOThreadIdCompleter,
      .help = N_("IOThread to be used by supported device")
     },
     {.name = "cache",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("cache mode of disk device")
     },
     {.name = "io",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("io policy of disk device")
     },
     {.name = "type",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("target device type")
     },
     {.name = "shareable",
@@ -474,29 +467,24 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     {.name = "mode",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("mode of device reading and writing")
     },
     {.name = "sourcetype",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("type of source (block|file|network)")
     },
     {.name = "serial",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("serial of disk device")
     },
     {.name = "wwn",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("wwn of disk device")
     },
     {.name = "alias",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("custom alias name of disk device")
     },
@@ -506,7 +494,6 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     {.name = "address",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("address of disk device")
     },
@@ -520,23 +507,19 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     {.name = "source-protocol",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("protocol used by disk device source")
     },
     {.name = "source-host-name",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("host name for source of disk device")
     },
     {.name = "source-host-transport",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("host transport for source of disk device")
     },
     {.name = "source-host-socket",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("host socket for source of disk device")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
@@ -1229,7 +1212,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "total-bytes-sec",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("total throughput limit, as scaled integer (default bytes)")
     },
     {.name = "read_bytes_sec",
@@ -1238,7 +1220,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "read-bytes-sec",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("read throughput limit, as scaled integer (default bytes)")
     },
     {.name = "write_bytes_sec",
@@ -1247,7 +1228,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "write-bytes-sec",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help =  N_("write throughput limit, as scaled integer (default bytes)")
     },
     {.name = "total_iops_sec",
@@ -1256,7 +1236,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "total-iops-sec",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("total I/O operations limit per second")
     },
     {.name = "read_iops_sec",
@@ -1265,7 +1244,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "read-iops-sec",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("read I/O operations limit per second")
     },
     {.name = "write_iops_sec",
@@ -1274,7 +1252,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "write-iops-sec",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("write I/O operations limit per second")
     },
     {.name = "total_bytes_sec_max",
@@ -1283,7 +1260,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "total-bytes-sec-max",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("total max, as scaled integer (default bytes)")
     },
     {.name = "read_bytes_sec_max",
@@ -1292,7 +1268,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "read-bytes-sec-max",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("read max, as scaled integer (default bytes)")
     },
     {.name = "write_bytes_sec_max",
@@ -1301,7 +1276,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "write-bytes-sec-max",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("write max, as scaled integer (default bytes)")
     },
     {.name = "total_iops_sec_max",
@@ -1310,7 +1284,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "total-iops-sec-max",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("total I/O operations max")
     },
     {.name = "read_iops_sec_max",
@@ -1319,7 +1292,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "read-iops-sec-max",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("read I/O operations max")
     },
     {.name = "write_iops_sec_max",
@@ -1328,7 +1300,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "write-iops-sec-max",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("write I/O operations max")
     },
     {.name = "size_iops_sec",
@@ -1337,7 +1308,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "size-iops-sec",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("I/O size in bytes")
     },
     {.name = "group_name",
@@ -1346,7 +1316,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "group-name",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("group name to share I/O quota between multiple drives")
     },
@@ -1356,7 +1325,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "total-bytes-sec-max-length",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("duration in seconds to allow total max bytes")
     },
     {.name = "read_bytes_sec_max_length",
@@ -1365,7 +1333,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "read-bytes-sec-max-length",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("duration in seconds to allow read max bytes")
     },
     {.name = "write_bytes_sec_max_length",
@@ -1374,7 +1341,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "write-bytes-sec-max-length",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("duration in seconds to allow write max bytes")
     },
     {.name = "total_iops_sec_max_length",
@@ -1383,7 +1349,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "total-iops-sec-max-length",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("duration in seconds to allow total I/O operations max")
     },
     {.name = "read_iops_sec_max_length",
@@ -1392,7 +1357,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "read-iops-sec-max-length",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("duration in seconds to allow read I/O operations max")
     },
     {.name = "write_iops_sec_max_length",
@@ -1401,7 +1365,6 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     {.name = "write-iops-sec-max-length",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("duration in seconds to allow write I/O operations max")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
@@ -3506,7 +3469,6 @@ static const vshCmdOptDef opts_dom_pm_suspend[] = {
     },
     {.name = "duration",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("duration in seconds")
     },
     {.name = NULL}
@@ -4544,7 +4506,6 @@ static const vshCmdOptDef opts_save_image_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
@@ -4950,7 +4911,6 @@ static const vshCmdOptDef opts_managed_save_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
@@ -5060,12 +5020,10 @@ static const vshCmdOptDef opts_schedinfo[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(0),
     {.name = "weight",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("weight for XEN_CREDIT")
     },
     {.name = "cap",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("cap for XEN_CREDIT")
     },
     VIRSH_COMMON_OPT_CURRENT(N_("get/set current scheduler info")),
@@ -8576,13 +8534,11 @@ static const vshCmdOptDef opts_send_key[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "codeset",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCodesetNameCompleter,
      .help = N_("the codeset of keycodes, default:linux")
     },
     {.name = "holdtime",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("the time (in milliseconds) how long the keys will be held")
     },
     {.name = "keycode",
@@ -9524,12 +9480,10 @@ static const vshCmdOptDef opts_domsetlaunchsecstate[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(0),
     {.name = "secrethdr",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("path to file containing the secret header"),
     },
     {.name = "secret",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("path to file containing the secret"),
     },
     {.name = "set-address",
@@ -9702,7 +9656,6 @@ static const vshCmdOptDef opts_qemu_monitor_command[] = {
     },
     {.name = "pass-fds",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("pass file descriptors N,M,... along with the command")
     },
@@ -10091,7 +10044,6 @@ static const vshCmdOptDef opts_qemu_agent_command[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "timeout",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("timeout seconds. must be positive.")
     },
     {.name = "async",
@@ -10329,7 +10281,6 @@ static const vshCmdOptDef opts_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
@@ -10441,7 +10392,6 @@ static const vshCmdOptDef opts_domxmltonative[] = {
     },
     {.name = "domain",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("domain name, id or uuid"),
      .completer = virshDomainNameCompleter,
     },
@@ -10797,49 +10747,40 @@ static const vshCmdOptDef opts_migrate[] = {
     },
     {.name = "disks-uri",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("URI to use for disks migration (overrides --disks-port)")
     },
     {.name = "comp-methods",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshDomainMigrateCompMethodsCompleter,
      .help = N_("comma separated list of compression methods to be used")
     },
     {.name = "comp-mt-level",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("compress level for multithread compression")
     },
     {.name = "comp-mt-threads",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("number of compression threads for multithread compression")
     },
     {.name = "comp-mt-dthreads",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("number of decompression threads for multithread compression")
     },
     {.name = "comp-xbzrle-cache",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("page cache size for xbzrle compression")
     },
     {.name = "auto-converge-initial",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("initial CPU throttling rate for auto-convergence")
     },
     {.name = "auto-converge-increment",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("CPU throttling rate increment for auto-convergence")
     },
     {.name = "persistent-xml",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompletePathLocalExisting,
      .help = N_("filename containing updated persistent XML for the target")
     },
@@ -10849,38 +10790,31 @@ static const vshCmdOptDef opts_migrate[] = {
     },
     {.name = "postcopy-bandwidth",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("post-copy migration bandwidth limit in MiB/s")
     },
     {.name = "parallel",
      .type = VSH_OT_BOOL,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("enable parallel migration")
     },
     {.name = "parallel-connections",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("number of connections for parallel migration")
     },
     {.name = "bandwidth",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("migration bandwidth limit in MiB/s")
     },
     {.name = "tls-destination",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("override the destination host name used for TLS verification")
     },
     {.name = "comp-zlib-level",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("compress level for zlib compression")
     },
     {.name = "comp-zstd-level",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("compress level for zstd compression")
     },
     {.name = NULL}
@@ -11439,7 +11373,6 @@ static const vshCmdOptDef opts_migrate_compcache[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "size",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("requested size of the cache (in bytes) used for compression")
     },
     {.name = NULL}
@@ -13100,7 +13033,6 @@ static const vshCmdOptDef opts_guest_agent_timeout[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(0),
     {.name = "timeout",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("timeout seconds.")
     },
     {.name = NULL}
@@ -13448,7 +13380,6 @@ static const vshCmdOptDef opts_domdisplay_reload[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(0),
     {.name = "type",
      .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("graphics display type")
     },
     {.name = NULL}
index 52e0dc55debcc48f45d253e3c9a1fb7220484da4..c338b5cd85a379a4567de23a79701906035d6c7d 100644 (file)
@@ -45,7 +45,6 @@ static const vshCmdInfo info_capabilities = {
 static const vshCmdOptDef opts_capabilities[] = {
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
@@ -108,7 +107,6 @@ static const vshCmdOptDef opts_domcapabilities[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index a08bb822edfebf970b91e0f50c558fb7085e4383..755c0d6455f3e3e5ea300bb7dc6ce1c5eec416af 100644 (file)
@@ -453,7 +453,6 @@ static const vshCmdOptDef opts_interface_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index 5bc91a361f72aa9a41905dc2cfbb43fca6ec57bd..065e59c3a15cc1e0524cd25ec753b794d784ca03 100644 (file)
@@ -639,7 +639,6 @@ static const vshCmdOptDef opts_network_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
@@ -1874,7 +1873,6 @@ static const vshCmdOptDef opts_network_port_dumpxml[] = {
     VIRSH_COMMON_OPT_NETWORK_PORT(0),
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index fafebf9972767fe351922bb149edeb6c8b4fa59c..b0563395f04b5f8b1f9c98a0c6606c9948aa1762 100644 (file)
@@ -584,7 +584,6 @@ static const vshCmdOptDef opts_node_device_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index f54d2a0ae50468b81b78019ed696309db599c019..69473b4935d6d5d0c1a80a333d98b60dc5edfa4a 100644 (file)
@@ -175,7 +175,6 @@ static const vshCmdOptDef opts_nwfilter_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
@@ -577,7 +576,6 @@ static const vshCmdOptDef opts_nwfilter_binding_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index c93204dd30f4839a2f4dc1dab4bf0b49b57964f5..aff1201ef73af9360b8b286fb6b3dec169ed4a18 100644 (file)
@@ -748,7 +748,6 @@ static const vshCmdOptDef opts_pool_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index edf3c4736225ad462c09ab35a6b137a5e2f71efd..56534518626b74a68a26d4715557458255785824 100644 (file)
@@ -131,7 +131,6 @@ static const vshCmdOptDef opts_secret_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
@@ -187,7 +186,6 @@ static const vshCmdOptDef opts_secret_set_value[] = {
     },
     {.name = "file",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompletePathLocalExisting,
      .help = N_("read secret from file"),
     },
index 2fcf6e3d5e9cf6eabc63dc3eef3b102432742563..d64649a8da2e5361b84345795ff67dd74b9ac4db 100644 (file)
@@ -359,7 +359,6 @@ static const vshCmdOptDef opts_snapshot_create_as[] = {
     },
     {.name = "memspec",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("memory attributes: [file=]name[,snapshot=type]")
     },
     {.name = "diskspec",
@@ -1587,7 +1586,6 @@ static const vshCmdOptDef opts_snapshot_dumpxml[] = {
     },
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index 4e5673e0ee1e9d7014231e90c700ed172b05d55f..67a6f2eda013b33c8a7ff52248861ed207462f02 100644 (file)
@@ -1130,7 +1130,6 @@ static const vshCmdOptDef opts_vol_dumpxml[] = {
     VIRSH_COMMON_OPT_POOL_OPTIONAL,
     {.name = "xpath",
      .type = VSH_OT_STRING,
-     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("xpath expression to filter the XML document")
     },
index e369c02f6cd0d8b5eea01bc6e4514ba7efa7a997..04b417e9a87eec03d53c99d0f6328737a83b2815 100644 (file)
@@ -1010,7 +1010,6 @@ static const vshCmdOptDef opts_daemon_timeout[] = {
      .type = VSH_OT_INT,
      .required = true,
      .help = N_("number of seconds the daemon will run without any active connection"),
-     .flags = VSH_OFLAG_REQ_OPT
     },
     {.name = NULL}
 };
index 2c90ca44f777f2fbef434acfc2172520f4d5a968..1dac869413eeb902c8be8b9e6e723c0130f199f7 100644 (file)
@@ -244,14 +244,12 @@ static int disconnected; /* we may have been disconnected */
 static int
 vshCmddefCheckInternals(vshControl *ctl,
                         const vshCmdDef *cmd,
-                        bool missingCompleters,
-                        int brokenPositionals)
+                        bool missingCompleters)
 {
     size_t i;
     bool seenOptionalOption = false;
     const char *seenOptionalPositionalOption = NULL;
     g_auto(virBuffer) complbuf = VIR_BUFFER_INITIALIZER;
-    g_auto(virBuffer) posbuf = VIR_BUFFER_INITIALIZER;
 
     /* in order to perform the validation resolve the alias first */
     if (cmd->alias) {
@@ -328,29 +326,6 @@ vshCmddefCheckInternals(vshControl *ctl,
             }
         }
 
-        if (brokenPositionals >= 0) {
-            switch (opt->type) {
-            case VSH_OT_INT:
-            case VSH_OT_STRING:
-            case VSH_OT_ARGV:
-                if (brokenPositionals == 0 ||
-                    brokenPositionals == opt->type) {
-                    if (!(opt->flags & VSH_OFLAG_REQ_OPT) &&
-                        !(opt->positional || opt->unwanted_positional))
-                        virBufferStrcat(&posbuf, opt->name, ", ", NULL);
-                }
-                break;
-
-            case VSH_OT_BOOL:
-                /* only name is completed */
-                /* no point in completing numbers */
-            case VSH_OT_ALIAS:
-                /* alias is handled in the referenced command */
-            case VSH_OT_NONE:
-                break;
-            }
-        }
-
         /* allow at most one optional positional option */
         if (opt->positional && !opt->required) {
             if (seenOptionalPositionalOption) {
@@ -471,15 +446,10 @@ vshCmddefCheckInternals(vshControl *ctl,
     }
 
     virBufferTrim(&complbuf, ", ");
-    virBufferTrim(&posbuf, ", ");
 
     if (missingCompleters && virBufferUse(&complbuf) > 0)
         vshPrintExtra(ctl, "%s: %s\n", cmd->name, virBufferCurrentContent(&complbuf));
 
-    if (virBufferUse(&posbuf)) {
-        vshPrintExtra(ctl, "%s: %s\n", cmd->name, virBufferCurrentContent(&posbuf));
-    }
-
     return 0;
 }
 
@@ -508,7 +478,7 @@ vshCmddefOptParse(const vshCmdDef *cmd,
         if (opt->type == VSH_OT_ALIAS)
             continue; /* skip the alias option */
 
-        if (!(opt->flags & VSH_OFLAG_REQ_OPT))
+        if (opt->positional || opt->unwanted_positional)
             *opts_need_arg |= 1ULL << i;
 
         if (opt->required)
@@ -3387,11 +3357,6 @@ const vshCmdOptDef opts_selftest[] = {
      .type = VSH_OT_BOOL,
      .help = N_("output help for each command")
     },
-    {.name = "broken-positionals",
-     .type = VSH_OT_INT,
-     .flags = VSH_OFLAG_REQ_OPT,
-     .help = N_("debug positional args")
-    },
     {.name = NULL}
 };
 const vshCmdInfo info_selftest = {
@@ -3406,9 +3371,6 @@ cmdSelfTest(vshControl *ctl, const vshCmd *cmd)
     const vshCmdDef *def;
     bool completers = vshCommandOptBool(cmd, "completers-missing");
     bool dumphelp = vshCommandOptBool(cmd, "dump-help");
-    int brokenPositionals = -1;
-
-    ignore_value(vshCommandOptInt(ctl, cmd, "broken-positionals", &brokenPositionals));
 
     for (grp = cmdGroups; grp->name; grp++) {
         for (def = grp->commands; def->name; def++) {
@@ -3416,7 +3378,7 @@ cmdSelfTest(vshControl *ctl, const vshCmd *cmd)
             if (dumphelp && !def->alias)
                 vshCmddefHelp(def);
 
-            if (vshCmddefCheckInternals(ctl, def, completers, brokenPositionals) < 0)
+            if (vshCmddefCheckInternals(ctl, def, completers) < 0)
                 return false;
         }
     }
index fdcc89b12a276910c2b3bb72b37427e1efb7920b..02c35488b97dc8f421bd4a4cea05774d20618ff0 100644 (file)
@@ -99,7 +99,6 @@ typedef enum {
 enum {
     VSH_OFLAG_NONE     = 0,        /* without flags */
     VSH_OFLAG_EMPTY_OK = (1 << 1), /* empty string option allowed */
-    VSH_OFLAG_REQ_OPT  = (1 << 2), /* --optionname required */
 };
 
 /* forward declarations */