From: Dietmar Maurer Date: Wed, 13 Jun 2018 05:54:33 +0000 (+0200) Subject: generate_usage_str: do no generate help for unknown commands X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=commitdiff_plain;h=7e1ea9f29034aba2e765e40514a9971c1add21c8 generate_usage_str: do no generate help for unknown commands Before: ... USAGE: pvesm aaa zfsscan With this patch applied: no such command 'aaa' --- diff --git a/PVE/CLIHandler.pm b/PVE/CLIHandler.pm index 801f530..514906a 100644 --- a/PVE/CLIHandler.pm +++ b/PVE/CLIHandler.pm @@ -92,8 +92,8 @@ sub resolve_cmd { $cmd = $argv->[$i]; } $cmdstr .= " $cmd"; - last if !defined($def->{$cmd}); $def = $def->{$cmd}; + last if !defined($def); if (ref($def) eq 'ARRAY') { # could expand to a real command, rest of $argv are its arguments @@ -131,6 +131,7 @@ sub generate_usage_str { $cli_handler_class->can('string_param_file_mapping'); my ($subcmd, $def, undef, undef, $cmdstr) = resolve_cmd($cmd); + die "no such command '$cmd->[0]'\n" if !defined($def) && ref($cmd) eq 'ARRAY'; my $generate; $generate = sub {