summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
408976c)
For the CLI man pages and documentation, mapped parameters
('content' strings in API2 which are loaded from file paths
in CLI) get special treatment and are displayed with the
type 'filepath'.
raise_param_exc({ cmd => "no such command '$cmd'"}) if !$class;
my $pwcallback = $cli_handler_class->can('read_password');
raise_param_exc({ cmd => "no such command '$cmd'"}) if !$class;
my $pwcallback = $cli_handler_class->can('read_password');
+ my $stringfilemap = $cli_handler_class->can('string_param_file_mapping');
my $str = $class->usage_str($name, "$exename $cmd", $arg_param, $uri_param,
my $str = $class->usage_str($name, "$exename $cmd", $arg_param, $uri_param,
- $verbose ? 'full' : 'short', $pwcallback);
+ $verbose ? 'full' : 'short', $pwcallback,
+ $stringfilemap);
if ($verbose) {
print "$str\n";
} else {
if ($verbose) {
print "$str\n";
} else {
die "not initialized" if !$cli_handler_class;
my $pwcallback = $cli_handler_class->can('read_password');
die "not initialized" if !$cli_handler_class;
my $pwcallback = $cli_handler_class->can('read_password');
+ my $stringfilemap = $cli_handler_class->can('string_param_file_mapping');
my $synopsis = "*${name}* `help`\n\n";
my $synopsis = "*${name}* `help`\n\n";
- $synopsis .= $class->usage_str($name, $name, $arg_param, $uri_param, 'asciidoc', $pwcallback);
+ $synopsis .= $class->usage_str($name, $name, $arg_param, $uri_param,
+ 'asciidoc', $pwcallback, $stringfilemap);
die "not initialized" if !($cmddef && $exename && $cli_handler_class);
my $pwcallback = $cli_handler_class->can('read_password');
die "not initialized" if !($cmddef && $exename && $cli_handler_class);
my $pwcallback = $cli_handler_class->can('read_password');
+ my $stringfilemap = $cli_handler_class->can('string_param_file_mapping');
foreach my $cmd (sort keys %$cmddef) {
my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
my $str = $class->usage_str($name, "$exename $cmd", $arg_param,
foreach my $cmd (sort keys %$cmddef) {
my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
my $str = $class->usage_str($name, "$exename $cmd", $arg_param,
- $uri_param, 'asciidoc', $pwcallback);
+ $uri_param, 'asciidoc', $pwcallback,
+ $stringfilemap);
$synopsis .= "\n" if $oldclass && $oldclass ne $class;
$synopsis .= "$str\n\n";
$synopsis .= "\n" if $oldclass && $oldclass ne $class;
$synopsis .= "$str\n\n";
die "not initialized" if !$cli_handler_class;
my $pwcallback = $cli_handler_class->can('read_password');
die "not initialized" if !$cli_handler_class;
my $pwcallback = $cli_handler_class->can('read_password');
+ my $stringfilemap = $cli_handler_class->can('string_param_file_mapping');
my $synopsis = " $name help\n\n";
my $synopsis = " $name help\n\n";
- my $str = $class->usage_str($name, $name, $arg_param, $uri_param, 'long', $pwcallback);
+ my $str = $class->usage_str($name, $name, $arg_param, $uri_param, 'long', $pwcallback, $stringfilemap);
$str =~ s/^USAGE://;
$str =~ s/\n/\n /g;
$synopsis .= $str;
$str =~ s/^USAGE://;
$str =~ s/\n/\n /g;
$synopsis .= $str;
die "no pod file specified" if !$podfn;
my $pwcallback = $cli_handler_class->can('read_password');
die "no pod file specified" if !$podfn;
my $pwcallback = $cli_handler_class->can('read_password');
+ my $stringfilemap = $cli_handler_class->can('string_param_file_mapping');
foreach my $cmd (sorted_commands()) {
my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
my $str = $class->usage_str($name, "$exename $cmd", $arg_param,
foreach my $cmd (sorted_commands()) {
my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
my $str = $class->usage_str($name, "$exename $cmd", $arg_param,
- $uri_param, $style, $pwcallback);
+ $uri_param, $style, $pwcallback,
+ $stringfilemap);
$str =~ s/^USAGE: //;
$synopsis .= "\n" if $oldclass && $oldclass ne $class;
$str =~ s/^USAGE: //;
$synopsis .= "\n" if $oldclass && $oldclass ne $class;
die "not initialized" if !($cmddef && $exename && $cli_handler_class);
my $pwcallback = $cli_handler_class->can('read_password');
die "not initialized" if !($cmddef && $exename && $cli_handler_class);
my $pwcallback = $cli_handler_class->can('read_password');
+ my $stringfilemap = $cli_handler_class->can('string_param_file_mapping');
print "USAGE: $exename <COMMAND> [ARGS] [OPTIONS]\n\n";
foreach my $cmd (sort keys %$cmddef) {
my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
my $str = $class->usage_str($name, "$exename $cmd", $arg_param, $uri_param,
print "USAGE: $exename <COMMAND> [ARGS] [OPTIONS]\n\n";
foreach my $cmd (sort keys %$cmddef) {
my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
my $str = $class->usage_str($name, "$exename $cmd", $arg_param, $uri_param,
+ 'full', $pwcallback, $stringfilemap);
die "not initialized" if !($cmddef && $exename && $cli_handler_class);
my $pwcallback = $cli_handler_class->can('read_password');
die "not initialized" if !($cmddef && $exename && $cli_handler_class);
my $pwcallback = $cli_handler_class->can('read_password');
+ my $stringfilemap = $cli_handler_class->can('string_param_file_mapping');
print $fd "ERROR: $msg\n" if $msg;
print $fd "USAGE: $exename <COMMAND> [ARGS] [OPTIONS]\n";
print $fd "ERROR: $msg\n" if $msg;
print $fd "USAGE: $exename <COMMAND> [ARGS] [OPTIONS]\n";
my $oldclass;
foreach my $cmd (sorted_commands()) {
my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
my $oldclass;
foreach my $cmd (sorted_commands()) {
my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
- my $str = $class->usage_str($name, "$exename $cmd", $arg_param, $uri_param, 'short', $pwcallback);
+ my $str = $class->usage_str($name, "$exename $cmd", $arg_param, $uri_param, 'short', $pwcallback, $stringfilemap);
print $fd "\n" if $oldclass && $oldclass ne $class;
print $fd " $str";
$oldclass = $class;
print $fd "\n" if $oldclass && $oldclass ne $class;
print $fd " $str";
$oldclass = $class;
if (scalar(@$args) >= 1) {
if ($args->[0] eq 'help') {
my $str = "USAGE: $name help\n";
if (scalar(@$args) >= 1) {
if ($args->[0] eq 'help') {
my $str = "USAGE: $name help\n";
- $str .= $class->usage_str($name, $name, $arg_param, $uri_param, 'long', $pwcallback);
+ $str .= $class->usage_str($name, $name, $arg_param, $uri_param, 'long', $pwcallback, $stringfilemap);
print STDERR "$str\n\n";
return;
} elsif ($args->[0] eq 'bashcomplete') {
print STDERR "$str\n\n";
return;
} elsif ($args->[0] eq 'bashcomplete') {
# $format: 'asciidoc', 'pod' or 'text'
# $style: 'config', 'arg' or 'fixed'
my $get_property_description = sub {
# $format: 'asciidoc', 'pod' or 'text'
# $style: 'config', 'arg' or 'fixed'
my $get_property_description = sub {
- my ($name, $style, $phash, $format, $hidepw) = @_;
+ my ($name, $style, $phash, $format, $hidepw, $fileparams) = @_;
+ if ($fileparams && $type eq 'string') {
+ foreach my $elem (@$fileparams) {
+ if ($name eq $elem) {
+ $type = 'filepath';
+ last;
+ }
+ }
+ }
+
if ($format eq 'asciidoc') {
if ($style eq 'config') {
if ($format eq 'asciidoc') {
if ($style eq 'config') {
# 'full' ... also include description
# 'asciidoc' ... generate asciidoc for man pages (like 'full')
# $hidepw ... hide password option (use this if you provide a read passwork callback)
# 'full' ... also include description
# 'asciidoc' ... generate asciidoc for man pages (like 'full')
# $hidepw ... hide password option (use this if you provide a read passwork callback)
+# $stringfilemap ... mapping for string parameters to file path parameters
- my ($self, $name, $prefix, $arg_param, $fixed_param, $format, $hidepw) = @_;
+ my ($self, $name, $prefix, $arg_param, $fixed_param, $format, $hidepw, $stringfilemap) = @_;
$format = 'long' if !$format;
$format = 'long' if !$format;
- $opts .= &$get_property_description($base, 'arg', $prop->{$k}, 'text', $hidepw);
+ $opts .= &$get_property_description($base, 'arg', $prop->{$k}, 'text',
+ $hidepw, &$stringfilemap($name));
if (!$prop->{$k}->{optional}) {
$args .= " " if $args;
if (!$prop->{$k}->{optional}) {
$args .= " " if $args;
die $err if !$ec || $ec ne "PVE::Exception" || !$err->is_param_exc();
die $err if !$ec || $ec ne "PVE::Exception" || !$err->is_param_exc();
- $err->{usage} = $self->usage_str($name, $prefix, $arg_param, $fixed_param, 'short', $pwcallback);
+ $err->{usage} = $self->usage_str($name, $prefix, $arg_param, $fixed_param, 'short', $pwcallback, $stringfilemap);