mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-26 02:42:05 +00:00
getopt_usage: do not display $standard_output_options
Instead, simply add [FORMAT_OPTIONS] to the usage string.
This commit is contained in:
parent
ac6c61bf13
commit
62c66c47fb
@ -17,6 +17,33 @@ my $method_path_lookup = {};
|
|||||||
|
|
||||||
our $AUTOLOAD; # it's a package global
|
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 {
|
sub api_clone_schema {
|
||||||
my ($schema) = @_;
|
my ($schema) = @_;
|
||||||
|
|
||||||
@ -586,7 +613,16 @@ sub getopt_usage {
|
|||||||
my $schema = $info->{parameters};
|
my $schema = $info->{parameters};
|
||||||
my $name = $info->{name};
|
my $name = $info->{name};
|
||||||
my $prop = { %{$schema->{properties}} }; # copy
|
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 = '';
|
my $out = '';
|
||||||
|
|
||||||
@ -655,11 +691,15 @@ sub getopt_usage {
|
|||||||
if ($format eq 'asciidoc') {
|
if ($format eq 'asciidoc') {
|
||||||
$out .= "*${prefix}*";
|
$out .= "*${prefix}*";
|
||||||
$out .= " `$args`" if $args;
|
$out .= " `$args`" if $args;
|
||||||
$out .= $opts ? " `[OPTIONS]`\n" : "\n";
|
$out .= " `[OPTIONS]`" if $opts;
|
||||||
|
$out .= " `[FORMAT_OPTIONS]`" if $has_output_format_option;
|
||||||
|
$out .= "\n";
|
||||||
} else {
|
} else {
|
||||||
$out .= "USAGE: " if $format ne 'short';
|
$out .= "USAGE: " if $format ne 'short';
|
||||||
$out .= "$prefix $args";
|
$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';
|
return $out if $format eq 'short';
|
||||||
@ -747,33 +787,6 @@ my $replace_file_names_with_contents = sub {
|
|||||||
return $param;
|
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 {
|
sub add_standard_output_properties {
|
||||||
my ($propdef, $list) = @_;
|
my ($propdef, $list) = @_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user