Changeset 158

Show
Ignore:
Timestamp:
06/01/04 23:18:49 (4 years ago)
Author:
svn
Message:

Resolved ticket #1, allowing truncated commands.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • manage/trunk/CLI/CLI.pm

    r156 r158  
    217217                my $trackvar = 0; 
    218218 
     219                        # Skip if help 
     220                        next if $rx =~ /^HELP/; 
     221 
     222                        # Find out if this candidate is a unique minimum match 
     223                my $unique = 0; 
     224 
     225                        if (defined($token)) { 
     226                        my @candidates = grep(/^(?:\d+\)(?:\$))?$token/, keys(%cmd)); 
     227                                $unique = 1 if @candidates == 1 and $candidates[0] eq $key; 
     228                        } 
     229 
    219230                        # Remove ordering token 
    220231                        $rx =~ s/^\d+\)//; 
    221  
    222                         # Skip if help 
    223                         next if $rx =~ /^HELP/; 
    224232 
    225233                        # Remove variable tracking token 
     
    229237                        } 
    230238 
    231                         if ((!defined($token) and $rx eq 'ACTION') or (defined($token) and $token =~ /^(?:$rx)$/is)) { 
     239                        if ($unique or (!defined($token) and $rx eq 'ACTION') or (defined($token) and $token =~ /^(?:$rx)$/is)) { 
    232240                        my $type = ref($cmd{$key}); 
    233241 
     
    258266                return ('ERROR', $error); 
    259267        } else { 
     268                if (defined($token)) { 
     269                my @candidates = grep(/^(?:\d+\)(?:\$))?$token/, keys(%cmd)); 
     270 
     271                        return ('ERROR', "No unique candidates for '$token', candidates are '@candidates'") 
     272                                if @candidates > 1; 
     273                } 
    260274                return ('ERROR', "Unrecognized command '$token'."); 
    261275        } 
  • manage/trunk/manage

    r157 r158  
    1212use Term::ReadLine::Gnu; 
    1313use POSIX qw(ctermid floor); 
    14 use Text::Wrap; 
    1514use Fcntl qw(SEEK_SET SEEK_END SEEK_CUR O_RDONLY); 
    1615use IO::File; 
     
    217216                        ACTION => sub { 
    218217                                Term::ReadLine::Gnu->clear_history(); 
     218                                info("History cleared"); 
    219219                        }, 
    220220                        HELP => "Clear the command line history."