]> git.proxmox.com Git - pve-common.git/commit - src/PVE/JSONSchema.pm
get_options: allow optional arguments "arg_params" if no ambiguity
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 26 Aug 2020 19:21:03 +0000 (21:21 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 26 Aug 2020 19:21:05 +0000 (21:21 +0200)
commit804bc6219b2b6e6a4c717b8ea1dffd3a15debddf
tree211762767da18c3edfbbacb064c0d7cd1f20c9f0
parent1e49f2e7be1ee33762d5009f0123a883b7136d46
get_options: allow optional arguments "arg_params" if no ambiguity

If we run out of passed arguments from the user but still had defined
"arg_params" (those params which went after the command in fixed
order without option -- dashes) we always errored out with "not
enough arguments". But, there are situations where the remaining
arg_params are all marked as optional in the schema, so we do not
need to error out in that case.

A prime (future) use case is "pvesm prune-backups". Currently the
usage is:
> pvesm prune-backups storeid --prune-backups keep-last=1,keep-...

Because the "prune-backups" keep retention property is optional as it
can fallback to the one defined in the storage configuration.
With this patch we can make it an argument and allow the following
two usages:

1. As above, but avoiding the extra ugly --prune-backups
> pvesm prune-backups storeid keep-last=1,keep-...

2. Fallback to storage config:
> pvesm prune-backups storeid

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/JSONSchema.pm