cli_handler: make standard options opt-in

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>
This commit is contained in:
Thomas Lamprecht 2018-07-17 16:19:31 +02:00 committed by Wolfgang Bumiller
parent 7c7bc4623d
commit 11b30ba490

View File

@ -788,15 +788,19 @@ sub cli_handler {
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 $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);
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)) {