vsh: Annotate 'required' and 'positional' arguments explicitly

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa
2024-03-05 15:07:47 +01:00
parent 162b184d0e
commit ac150162fd
15 changed files with 283 additions and 4 deletions

View File

@@ -1568,6 +1568,8 @@ static const vshCmdOptDef opts_snapshot_dumpxml[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT),
{.name = "snapshotname",
.type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ,
.help = N_("snapshot name"),
.completer = virshSnapshotNameCompleter,