[PATCH 26/28] vsh: Make positional parsing of arguments opt-in

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tools/virsh-backup.c         |  1 -
 tools/virsh-checkpoint.c     |  1 -
 tools/virsh-domain-monitor.c |  1 -
 tools/virsh-domain.c         | 69 ------------------------------------
 tools/virsh-host.c           |  2 --
 tools/virsh-interface.c      |  1 -
 tools/virsh-network.c        |  2 --
 tools/virsh-nodedev.c        |  1 -
 tools/virsh-nwfilter.c       |  2 --
 tools/virsh-pool.c           |  1 -
 tools/virsh-secret.c         |  2 --
 tools/virsh-snapshot.c       |  2 --
 tools/virsh-volume.c         |  1 -
 tools/virt-admin.c           |  1 -
 tools/vsh.c                  | 44 ++---------------------
 tools/vsh.h                  |  1 -
 16 files changed, 3 insertions(+), 129 deletions(-)

diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c
index 52325b5ca0..9a1e89760f 100644
--- a/tools/virsh-backup.c
+++ b/tools/virsh-backup.c
@@ -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")
     },
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index 48e3a586e4..e425041ca7 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -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")
     },
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index d88cf64235..5531d3b737 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -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")),
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 600388dceb..91a9dfd96a 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -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}
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 52e0dc55de..c338b5cd85 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -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")
     },
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index a08bb822ed..755c0d6455 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -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")
     },
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 5bc91a361f..065e59c3a1 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -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")
     },
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index fafebf9972..b0563395f0 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -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")
     },
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index f54d2a0ae5..69473b4935 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -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")
     },
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index c93204dd30..aff1201ef7 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -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")
     },
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index edf3c47362..5653451862 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -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"),
     },
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 2fcf6e3d5e..d64649a8da 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -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")
     },
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 4e5673e0ee..67a6f2eda0 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -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")
     },
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index 514f434c94..9a29a67999 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -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}
 };
diff --git a/tools/vsh.c b/tools/vsh.c
index 2c90ca44f7..1dac869413 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -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;
         }
     }
diff --git a/tools/vsh.h b/tools/vsh.h
index fdcc89b12a..02c35488b9 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -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 */
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux