]> git.proxmox.com Git - pve-common.git/commitdiff
cli_handler: make standard options opt-in
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 17 Jul 2018 14:19:31 +0000 (16:19 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 18 Jul 2018 07:26:53 +0000 (09:26 +0200)
The new standard options overwrite some already existing options in
already existing CLI tools, which is surely no good, e.g. vzdump
already has an quiet option which now gets overwritten, thus any
backup triggered by CRON always sents out an (additional) email.

Further, they may even only have an effect if the respective CLI
command uses an CLIFormatter print* method to output things.

And for some commands, like 'pvecm status' they may even never make
sense, as they exec an external program which doesn't honors nor gets
those std options...
Also some internal commands, like 'qm mtunnel' will never use it, as
probably even "normal" commands, as it may simply not make sense for
every command..

So make it opt-in for now, any CLI command can set std-output-opts to
get them.

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

index af9024eacaed59da1320e51225b11c337d5afaee..8be15039e6aad28050e0a5e4a62e99241911c389 100644 (file)
@@ -788,15 +788,19 @@ sub cli_handler {
     my $info = $self->map_method_by_name($name);
     $options //= {};
 
     my $info = $self->map_method_by_name($name);
     $options //= {};
 
+    my $add_stdopts = $options->{'std-output-opts'};
+
     my $res;
     eval {
        my $param_map = {};
        $param_map = $compute_param_mapping_hash->($param_cb->($name)) if $param_cb;
     my $res;
     eval {
        my $param_map = {};
        $param_map = $compute_param_mapping_hash->($param_cb->($name)) if $param_cb;
-       my $schema = add_standard_output_parameters($info->{parameters});
+       my $schema = $add_stdopts ? add_standard_output_parameters($info->{parameters}) : $info->{properties} ;
        my $param = PVE::JSONSchema::get_options($schema, $args, $arg_param, $fixed_param, $param_map);
 
        my $param = PVE::JSONSchema::get_options($schema, $args, $arg_param, $fixed_param, $param_map);
 
-       foreach my $opt (keys %$standard_output_options) {
-           $options->{$opt} = delete $param->{$opt} if defined($param->{$opt});
+       if ($add_stdopts) {
+           foreach my $opt (keys %$standard_output_options) {
+               $options->{$opt} = delete $param->{$opt} if defined($param->{$opt});
+           }
        }
 
        if (defined($param_map)) {
        }
 
        if (defined($param_map)) {