Re: [PATCH 15/23] vsh: Annotate 'required' and 'positional' arguments explicitly

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

 



On a Monday in 2024, Peter Krempa wrote:
Add 'positional' and 'required' fields to vshCmdOptDef, which will
explicitly track the two properties of arguments.

To ensure that we have proper coverage, add checks to
vshCmddefCheckInternals validating the state of the above flags by
infering it from existing data.

This conversion will allow us:
- remove VSH_OT_DATA in favor of VSH_OT_STRING
- use VSH_OT_INT when required both as positional and non-positional
- properly annotate which VSH_OT_ARGV are positional and which are not
  (currently inferred by whether an previous positional option exists)

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
tools/virsh-domain-monitor.c |   5 ++
tools/virsh-domain.c         | 118 +++++++++++++++++++++++++++++++++++
tools/virsh-host.c           |  10 +++
tools/virsh-interface.c      |  12 ++++
tools/virsh-network.c        |  16 ++++-
tools/virsh-nodedev.c        |  20 ++++++
tools/virsh-nwfilter.c       |  10 +++
tools/virsh-pool.c           |   8 +++
tools/virsh-secret.c         |   8 +++
tools/virsh-snapshot.c       |   2 +
tools/virsh-volume.c         |  12 ++++
tools/virsh.h                |  16 +++--
tools/virt-admin.c           |  22 +++++++
tools/vsh.c                  |  32 +++++++++-
tools/vsh.h                  |   2 +
15 files changed, 286 insertions(+), 7 deletions(-)

diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 6f4a66b659..b9db3e061d 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -32,7 +32,9 @@

#define VIRSH_COMMON_OPT_NETWORK(_helpstr, cflags) \
    {.name = "network", \
-     .type = VSH_OT_DATA, \
+     .type = VSH_OT_DATA,\

Unrelated whitespace change.

+     .positional = true, \
+     .required = true, \
     .flags = VSH_OFLAG_REQ, \
     .help = _helpstr, \
     .completer = virshNetworkNameCompleter, \
diff --git a/tools/virsh.h b/tools/virsh.h
index 877b290e3a..3e8d998a5d 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -57,7 +57,9 @@
 */
#define VIRSH_COMMON_OPT_POOL(_helpstr, cflags) \
    {.name = "pool", \
-     .type = VSH_OT_DATA, \
+     .type = VSH_OT_DATA,\

Same here.

+     .positional = true, \
+     .required = true, \
     .flags = VSH_OFLAG_REQ, \
     .help = _helpstr, \
     .completer = virshStoragePoolNameCompleter, \
@@ -66,7 +68,9 @@

#define VIRSH_COMMON_OPT_DOMAIN(_helpstr, cflags) \
    {.name = "domain", \
-     .type = VSH_OT_DATA, \
+     .type = VSH_OT_DATA,\

And here.

+     .positional = true, \
+     .required = true, \
     .flags = VSH_OFLAG_REQ, \
     .help = _helpstr, \
     .completer = virshDomainNameCompleter, \

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature

_______________________________________________
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