getopt_usage: do not display $standard_output_options

Instead, simply add [FORMAT_OPTIONS] to the usage string.
This commit is contained in:
Dietmar Maurer 2018-07-26 13:58:50 +02:00
parent ac6c61bf13
commit 62c66c47fb

View File

@ -17,6 +17,33 @@ my $method_path_lookup = {};
our $AUTOLOAD; # it's a package global
our $standard_output_options = {
'output-format' => PVE::JSONSchema::get_standard_option('pve-output-format'),
noheader => {
description => "Do not show column headers (for 'text' format).",
type => 'boolean',
optional => 1,
default => 1,
},
noborder => {
description => "Do not draw borders (for 'text' format).",
type => 'boolean',
optional => 1,
default => 1,
},
quiet => {
description => "Suppress printing results.",
type => 'boolean',
optional => 1,
},
'human-readable' => {
description => "Call output rendering functions to produce human readable text.",
type => 'boolean',
optional => 1,
default => 1,
}
};
sub api_clone_schema {
my ($schema) = @_;
@ -586,7 +613,16 @@ sub getopt_usage {
my $schema = $info->{parameters};
my $name = $info->{name};
my $prop = { %{$schema->{properties}} }; # copy
$prop = { %$prop, %$formatter_properties } if $formatter_properties;
my $has_output_format_option = $formatter_properties->{'output-format'} ? 1 : 0;
if ($formatter_properties) {
foreach my $key (keys %$formatter_properties) {
if (!$standard_output_options->{$key}) {
$prop->{$key} = $formatter_properties->{$key};
}
}
}
my $out = '';
@ -655,11 +691,15 @@ sub getopt_usage {
if ($format eq 'asciidoc') {
$out .= "*${prefix}*";
$out .= " `$args`" if $args;
$out .= $opts ? " `[OPTIONS]`\n" : "\n";
$out .= " `[OPTIONS]`" if $opts;
$out .= " `[FORMAT_OPTIONS]`" if $has_output_format_option;
$out .= "\n";
} else {
$out .= "USAGE: " if $format ne 'short';
$out .= "$prefix $args";
$out .= $opts ? " [OPTIONS]\n" : "\n";
$out .= " [OPTIONS]" if $opts;
$out .= " [FORMAT_OPTIONS]" if $has_output_format_option;
$out .= "\n";
}
return $out if $format eq 'short';
@ -747,33 +787,6 @@ my $replace_file_names_with_contents = sub {
return $param;
};
our $standard_output_options = {
'output-format' => PVE::JSONSchema::get_standard_option('pve-output-format'),
noheader => {
description => "Do not show column headers (for 'text' format).",
type => 'boolean',
optional => 1,
default => 1,
},
noborder => {
description => "Do not draw borders (for 'text' format).",
type => 'boolean',
optional => 1,
default => 1,
},
quiet => {
description => "Suppress printing results.",
type => 'boolean',
optional => 1,
},
'human-readable' => {
description => "Call output rendering functions to produce human readable text.",
type => 'boolean',
optional => 1,
default => 1,
}
};
sub add_standard_output_properties {
my ($propdef, $list) = @_;