[pve-devel] [PATCH common v2 6/9] cli: factor out generate usage string
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Dec 29 12:31:38 CET 2017
On Mon, Dec 18, 2017 at 10:21:40AM +0100, Thomas Lamprecht wrote:
> reduce code reuse and prepare for sub commands
>
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
> src/PVE/CLIHandler.pm | 138 ++++++++++++++++++++++++++++----------------------
> 1 file changed, 77 insertions(+), 61 deletions(-)
>
> diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
> index 061adb6..7d0804d 100644
> --- a/src/PVE/CLIHandler.pm
> +++ b/src/PVE/CLIHandler.pm
> @@ -40,6 +40,57 @@ my $complete_command_names = sub {
> return [ sort keys %$cmddef ];
> };
>
> +sub generate_usage_str {
> + my ($format, $cmd, $indent, $separator, $sortfunc) = @_;
> +
> + $assert_initialized->();
> + die 'format required' if !$format;
> +
> + $sortfunc //= sub { sort keys %{$_[0]} };
> + $separator //= '';
> + $indent //= '';
> +
> + my $can_read_pass = $cli_handler_class->can('read_password');
> + my $can_str_param_fmap = $cli_handler_class->can('string_param_file_mapping');
> +
> + my $def = $cmddef;
> + $def = $def->{$cmd} if $cmd && ref($def}) eq 'HASH' && $def->{$cmd};
Typo here ('}' after $def).
More information about the pve-devel
mailing list