]> git.proxmox.com Git - pve-common.git/commitdiff
cli: allow to pass sub commands to help as array
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 9 Jan 2018 12:25:32 +0000 (13:25 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 18 Jan 2018 07:59:34 +0000 (08:59 +0100)
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@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/CLIHandler.pm

index 9609181816a58632898795765aa4e9d9e1f4ca81..1af9987c56c65d6b12a239df14177ae29627d632 100644 (file)
@@ -158,12 +158,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',
@@ -178,9 +176,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) {
@@ -438,7 +436,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);