diff --git a/battleman.py b/battleman.py index b6d944a..bbcaa9f 100755 --- a/battleman.py +++ b/battleman.py @@ -96,6 +96,20 @@ class CommandParser(cmd.Cmd): self.bp_io_failed = True + # This allows us to do partial command completion without , + # 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]