Added partial command completion
This commit is contained in:
parent
db5ceef1a8
commit
22bb0255c1
14
battleman.py
14
battleman.py
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue
Block a user