Added partial command completion

This commit is contained in:
Anna Rose 2012-03-31 17:38:01 -04:00
parent db5ceef1a8
commit 22bb0255c1

View File

@ -96,6 +96,20 @@ class CommandParser(cmd.Cmd):
self.bp_io_failed = True
# This allows us to do partial command completion without <tab>,
# as long as
def default(self, line):
cmd, data, line = self.parseline(line)
cmds = self.completenames(cmd)
num_cmds = len(cmds)
if num_cmds == 1:
getattr(self, 'do_'+cmds[0])(data)
elif num_cmds > 1:
sys.stdout.write('Error: Ambiguous command: {}'.format(cmd))
else:
print 'Error: Unrecognized command {}'.format(cmd)
# a
def do_add(self, line):
"""add [N]