[pve-devel] [PATCH common] CLI/RESTHandler: more generic parameter mapping

Dietmar Maurer dietmar at proxmox.com
Fri Mar 2 07:13:30 CET 2018


Those renames disturb the whole patch:

>      my $can_read_pass = $cli_handler_class->can('read_password');
> -    my $can_str_param_fmap =
> $cli_handler_class->can('string_param_file_mapping');
> +    my $can_map_params = $cli_handler_class->can('param_mapping') ||
> +			 $cli_handler_class->can('string_param_file_mapping');

The functional change is quite easy, but

>  
>      my ($subcmd, $def) = resolve_cmd($cmd);
>  
> @@ -138,7 +139,7 @@ sub generate_usage_str {
>  		    $str .= $indent;
>  		    $str .= $class->usage_str($name, "$prefix $cmd", $arg_param,
>  		                              $fixed_param, $format,
> -		                              $can_read_pass, $can_str_param_fmap);
> +		                              $can_read_pass, $can_map_params);

but the rename causes the diff to grow ...

>  		    $oldclass = $class;
>  
>  		} elsif (defined($def->{$cmd}->{alias}) && ($format eq 'asciidoc')) {
> @@ -162,7 +163,7 @@ sub generate_usage_str {
>  
>  	    $str .= $indent;
>  	    $str .= $class->usage_str($name, $prefix, $arg_param, $fixed_param,
> $format,
> -	                              $can_read_pass, $can_str_param_fmap);
> +	                              $can_read_pass, $can_map_params);

same here

>  	}
>  	return $str;
>      };
> @@ -546,7 +547,8 @@ 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 = $cli_handler_class->can('param_mapping') ||
> +			$cli_handler_class->can('string_param_file_mapping');

again, a simple functional change.
>  
>      $exename = &$get_exe_name($class);
>  
> @@ -556,9 +558,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);

and useless changes due to the rename

>      } else {
> -	&$handle_cmd(\@ARGV, $pwcallback, $preparefunc, $stringfilemap);
> +	&$handle_cmd(\@ARGV, $pwcallback, $preparefunc, $param_mapping);

same here

...




More information about the pve-devel mailing list