[pve-devel] [PATCH common v2 8/9] cli: allow to pass sub commands to help as array
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Dec 29 12:42:04 CET 2017
On Mon, Dec 18, 2017 at 10:21:42AM +0100, Thomas Lamprecht wrote:
> Improves usabillity by allowing to pass a sub copmmand unquoted to
> the help command, e.g.:
>
> # pveum help user delete
>
> without this only a quoted version worked, e.g.:
> # pveum help "user delete"
>
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
once the rest is finished:
Acked-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> ---
> src/PVE/CLIHandler.pm | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
> index 996ddfd..76b14c9 100644
> --- a/src/PVE/CLIHandler.pm
> +++ b/src/PVE/CLIHandler.pm
> @@ -155,12 +155,10 @@ __PACKAGE__->register_method ({
> parameters => {
> additionalProperties => 0,
> properties => {
> - cmd => {
> - description => "Command name",
> - type => 'string',
> - optional => 1,
> + 'extra-args' => PVE::JSONSchema::get_standard_option('extra-args', {
> + description => 'Shows help for a specific command',
> completion => $complete_command_names,
> - },
> + }),
> verbose => {
> description => "Verbose output format.",
> type => 'boolean',
> @@ -175,9 +173,9 @@ __PACKAGE__->register_method ({
>
> $assert_initialized->();
>
> - my $cmd = $param->{cmd};
> + my $cmd = $param->{'extra-args'};
>
> - my $verbose = defined($cmd) && $cmd;
> + my $verbose = defined($cmd) && $cmd;
> $verbose = $param->{verbose} if defined($param->{verbose});
>
> if (!$cmd) {
> @@ -435,7 +433,7 @@ sub setup_environment {
> my $handle_cmd = sub {
> my ($args, $pwcallback, $preparefunc, $stringfilemap) = @_;
>
> - $cmddef->{help} = [ __PACKAGE__, 'help', ['cmd'] ];
> + $cmddef->{help} = [ __PACKAGE__, 'help', ['extra-args'] ];
>
> my $cmd_str = join(' ', @$args);
> my ($cmd, $def, $cmd_args) = resolve_cmd($args);
> --
> 2.11.0
More information about the pve-devel
mailing list