Before:

...
USAGE: pvesm aaa zfsscan

With this patch applied:

no such command 'aaa'

Signed-off-by: Dietmar Maurer <diet...@proxmox.com>
---
 src/PVE/CLIHandler.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
index 316d29d..5cdffa3 100644
--- a/src/PVE/CLIHandler.pm
+++ b/src/PVE/CLIHandler.pm
@@ -93,8 +93,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
@@ -132,6 +132,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 {
-- 
2.11.0

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to