Search and execute short command alias
This commit is contained in:
parent
26392b14fc
commit
37c68b7ba6
1 changed files with 17 additions and 0 deletions
|
|
@ -322,6 +322,23 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
stop = None
|
stop = None
|
||||||
return stop
|
return stop
|
||||||
|
|
||||||
|
def parseline(self, line):
|
||||||
|
"""
|
||||||
|
This REPL method is overrided to search "short" alias of commands
|
||||||
|
"""
|
||||||
|
cmd, arg, ignored = Cmd.parseline(self, line)
|
||||||
|
|
||||||
|
names = set(name for name in self.get_names() if name.startswith('do_'))
|
||||||
|
|
||||||
|
if 'do_' + cmd not in names:
|
||||||
|
long = set(name for name in names if name.startswith('do_' + cmd))
|
||||||
|
# if more than one result, ambiguous command, do nothing (error will display suggestions)
|
||||||
|
if len(long) == 1:
|
||||||
|
cmd = long.pop()[3:]
|
||||||
|
|
||||||
|
return cmd, arg, ignored
|
||||||
|
|
||||||
|
|
||||||
def onecmd(self, line):
|
def onecmd(self, line):
|
||||||
"""
|
"""
|
||||||
This REPL method is overrided to catch some particular exceptions.
|
This REPL method is overrided to catch some particular exceptions.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue