5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-22 21:33:47 +03:00

rename $stringfilemap to $param_mapping_func

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2018-03-02 12:37:19 +01:00 committed by Wolfgang Bumiller
parent dfc6cff8e3
commit b01af86160
2 changed files with 15 additions and 15 deletions

View File

@ -457,7 +457,7 @@ sub setup_environment {
}
my $handle_cmd = sub {
my ($args, $pwcallback, $preparefunc, $stringfilemap) = @_;
my ($args, $pwcallback, $preparefunc, $param_mapping_func) = @_;
$cmddef->{help} = [ __PACKAGE__, 'help', ['extra-args'] ];
@ -489,13 +489,13 @@ my $handle_cmd = sub {
$abort->("unknown command '$cmd_str'") if !$class;
my $prefix = "$exename $cmd_str";
my $res = $class->cli_handler($prefix, $name, $cmd_args, $arg_param, $uri_param, $pwcallback, $stringfilemap);
my $res = $class->cli_handler($prefix, $name, $cmd_args, $arg_param, $uri_param, $pwcallback, $param_mapping_func);
&$outsub($res) if $outsub;
};
my $handle_simple_cmd = sub {
my ($args, $pwcallback, $preparefunc, $stringfilemap) = @_;
my ($args, $pwcallback, $preparefunc, $param_mapping_func) = @_;
my ($class, $name, $arg_param, $uri_param, $outsub) = @{$cmddef};
die "no class specified" if !$class;
@ -524,7 +524,7 @@ my $handle_simple_cmd = sub {
&$preparefunc() if $preparefunc;
my $res = $class->cli_handler($name, $name, \@ARGV, $arg_param, $uri_param, $pwcallback, $stringfilemap);
my $res = $class->cli_handler($name, $name, \@ARGV, $arg_param, $uri_param, $pwcallback, $param_mapping_func);
&$outsub($res) if $outsub;
};
@ -546,7 +546,7 @@ sub run_cli_handler {
my $preparefunc = $params{prepare};
my $pwcallback = $class->can('read_password');
my $stringfilemap = $class->can('string_param_file_mapping');
my $param_mapping_func = $class->can('string_param_file_mapping');
$exename = &$get_exe_name($class);
@ -556,9 +556,9 @@ sub run_cli_handler {
$cmddef = ${"${class}::cmddef"};
if (ref($cmddef) eq 'ARRAY') {
&$handle_simple_cmd(\@ARGV, $pwcallback, $preparefunc, $stringfilemap);
&$handle_simple_cmd(\@ARGV, $pwcallback, $preparefunc, $param_mapping_func);
} else {
&$handle_cmd(\@ARGV, $pwcallback, $preparefunc, $stringfilemap);
&$handle_cmd(\@ARGV, $pwcallback, $preparefunc, $param_mapping_func);
}
exit 0;

View File

@ -541,9 +541,9 @@ my $compute_param_mapping_hash = sub {
# 'full' ... text, 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
# $param_mapping_func ... mapping for string parameters to file path parameters
sub usage_str {
my ($self, $name, $prefix, $arg_param, $fixed_param, $format, $hidepw, $stringfilemap) = @_;
my ($self, $name, $prefix, $arg_param, $fixed_param, $format, $hidepw, $param_mapping_func) = @_;
$format = 'long' if !$format;
@ -600,8 +600,8 @@ sub usage_str {
}
}
my $param_mapping_hash = $compute_param_mapping_hash->(&$stringfilemap($name))
if $stringfilemap;
my $param_mapping_hash = $compute_param_mapping_hash->(&$param_mapping_func($name))
if $param_mapping_func;
$opts .= &$get_property_description($base, 'arg', $prop->{$k}, $format,
$hidepw, $param_mapping_hash->{$k});
@ -699,7 +699,7 @@ my $replace_file_names_with_contents = sub {
};
sub cli_handler {
my ($self, $prefix, $name, $args, $arg_param, $fixed_param, $pwcallback, $stringfilemap) = @_;
my ($self, $prefix, $name, $args, $arg_param, $fixed_param, $pwcallback, $param_mapping_func) = @_;
my $info = $self->map_method_by_name($name);
@ -707,8 +707,8 @@ sub cli_handler {
eval {
my $param = PVE::JSONSchema::get_options($info->{parameters}, $args, $arg_param, $fixed_param, $pwcallback);
if (defined($stringfilemap)) {
my $param_mapping_hash = $compute_param_mapping_hash->(&$stringfilemap($name));
if (defined($param_mapping_func)) {
my $param_mapping_hash = $compute_param_mapping_hash->(&$param_mapping_func($name));
&$replace_file_names_with_contents($param, $param_mapping_hash);
}
@ -719,7 +719,7 @@ sub cli_handler {
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, $stringfilemap);
$err->{usage} = $self->usage_str($name, $prefix, $arg_param, $fixed_param, 'short', $pwcallback, $param_mapping_func);
die $err;
}