X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=blobdiff_plain;f=PVE%2FAPIClient%2FCLIHandler.pm;h=1c39dd1e2321ac80cd410729c910bf6454b88c56;hp=a5017f6f8cf934cef0aedcfa93d5f70e70935cc7;hb=50d8425652ad9c169170b02ed7c5df0813fbb0b3;hpb=b40074253447b60e2afad198872315e448da18f1 diff --git a/PVE/APIClient/CLIHandler.pm b/PVE/APIClient/CLIHandler.pm index a5017f6..1c39dd1 100644 --- a/PVE/APIClient/CLIHandler.pm +++ b/PVE/APIClient/CLIHandler.pm @@ -4,6 +4,7 @@ use strict; use warnings; use PVE::APIClient::SafeSyslog; +use PVE::APIClient::Exception qw(raise raise_param_exc); use PVE::APIClient::RESTHandler; @@ -53,7 +54,9 @@ my $expand_command_name = sub { return $cmd if exists $def->{$cmd}; # command is already complete - my @expanded = grep { /^\Q$cmd\E/ } keys %$def; + my $is_alias = sub { ref($_[0]) eq 'HASH' && exists($_[0]->{alias}) }; + my @expanded = grep { /^\Q$cmd\E/ && !$is_alias->($def->{$_}) } keys %$def; + return $expanded[0] if scalar(@expanded) == 1; # enforce exact match return undef; @@ -488,7 +491,7 @@ my $handle_cmd = sub { } # checked special commands, if def is still a hash we got an incomplete sub command - $abort->("incomplete command '$cmd_str'") if ref($def) eq 'HASH'; + $abort->("incomplete command '$cmd_str'", $args) if ref($def) eq 'HASH'; &$preparefunc() if $preparefunc;