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' && $_[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;
$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
$cli_handler_class->can('string_param_file_mapping');
my ($subcmd, $def, undef, undef, $cmdstr) = resolve_cmd($cmd);
+ $abort->("unknown command '$cmdstr'") if !defined($def) && ref($cmd) eq 'ARRAY';
my $generate;
$generate = sub {