don't crash when there the input is empty
This commit is contained in:
parent
460574785d
commit
538578c83f
1 changed files with 12 additions and 10 deletions
|
|
@ -328,17 +328,18 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
"""
|
"""
|
||||||
cmd, arg, ignored = Cmd.parseline(self, line)
|
cmd, arg, ignored = Cmd.parseline(self, line)
|
||||||
|
|
||||||
names = set(name for name in self.get_names() if name.startswith('do_'))
|
if cmd is not None:
|
||||||
|
names = set(name for name in self.get_names() if name.startswith('do_'))
|
||||||
|
|
||||||
if 'do_' + cmd not in names:
|
if 'do_' + cmd not in names:
|
||||||
long = set(name for name in names if name.startswith('do_' + cmd))
|
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 more than one result, ambiguous command, do nothing (error will display suggestions)
|
||||||
if len(long) == 1:
|
if len(long) == 1:
|
||||||
cmd = long.pop()[3:]
|
cmd = long.pop()[3:]
|
||||||
|
|
||||||
return cmd, arg, ignored
|
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.
|
||||||
|
|
@ -378,9 +379,10 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
def default(self, line):
|
def default(self, line):
|
||||||
print >>sys.stderr, 'Unknown command: "%s"' % line
|
print >>sys.stderr, 'Unknown command: "%s"' % line
|
||||||
cmd, arg, ignore = Cmd.parseline(self, line)
|
cmd, arg, ignore = Cmd.parseline(self, line)
|
||||||
names = set(name[3:] for name in self.get_names() if name.startswith('do_' + cmd))
|
if cmd is not None:
|
||||||
if len(names) > 0:
|
names = set(name[3:] for name in self.get_names() if name.startswith('do_' + cmd))
|
||||||
print >>sys.stderr, 'Do you mean %s?' % ' '.join(names)
|
if len(names) > 0:
|
||||||
|
print >>sys.stderr, 'Do you mean: %s?' % ', '.join(names)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
def completenames(self, text, *ignored):
|
def completenames(self, text, *ignored):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue