comparison cmd2.py @ 237:e91808980e59

fixed bug in abbreviated commands
author catherine@dellzilla
date Tue, 24 Mar 2009 14:11:49 -0400
parents 035330ccfcf0
children a31cf334bc16
comparison
equal deleted inserted replaced
236:035330ccfcf0 237:e91808980e59
281 def do_cmdenvironment(self, args): 281 def do_cmdenvironment(self, args):
282 '''Summary report of interactive parameters.''' 282 '''Summary report of interactive parameters.'''
283 self.stdout.write(""" 283 self.stdout.write("""
284 Commands are %(casesensitive)scase-sensitive. 284 Commands are %(casesensitive)scase-sensitive.
285 Commands may be terminated with: %(terminators)s 285 Commands may be terminated with: %(terminators)s
286 Settable parameters: %(settable)s 286 Settable parameters: %(settable)s\n""" % \
287 """ %
288 { 'casesensitive': (self.case_insensitive and 'not ') or '', 287 { 'casesensitive': (self.case_insensitive and 'not ') or '',
289 'terminators': str(self.terminators), 288 'terminators': str(self.terminators),
290 'settable': ' '.join(self.settable) 289 'settable': ' '.join(self.settable)
291 }) 290 })
292 291
622 try: 621 try:
623 func = getattr(self, 'do_' + statement.parsed.command) 622 func = getattr(self, 'do_' + statement.parsed.command)
624 except AttributeError: 623 except AttributeError:
625 func = None 624 func = None
626 if self.abbrev: # accept shortened versions of commands 625 if self.abbrev: # accept shortened versions of commands
627 funcs = [f for (fname, function) in inspect.getmembers(self, inspect.ismethod) 626 funcs = [(fname, function) for (fname, function) in inspect.getmembers(self, inspect.ismethod)
628 if fname.startswith('do_' + statement.parsed.command)] 627 if fname.startswith('do_' + statement.parsed.command)]
629 if len(funcs) == 1: 628 if len(funcs) == 1:
630 func = funcs[0] 629 func = funcs[0][1]
631 if not func: 630 if not func:
632 return self.postparsing_postcmd(self.default(statement)) 631 return self.postparsing_postcmd(self.default(statement))
633 timestart = datetime.datetime.now() 632 timestart = datetime.datetime.now()
634 stop = func(statement) 633 stop = func(statement)
635 if self.timing: 634 if self.timing:
807 self.pystate['quit'] = quit 806 self.pystate['quit'] = quit
808 self.pystate['exit'] = quit 807 self.pystate['exit'] = quit
809 self.pystate[self.nonpythoncommand] = onecmd 808 self.pystate[self.nonpythoncommand] = onecmd
810 try: 809 try:
811 interp.interact() 810 interp.interact()
812 except SystemExit:
813 quit()
814 except EmbeddedConsoleExit: 811 except EmbeddedConsoleExit:
815 return 812 return
816 813
817 def do_history(self, arg): 814 def do_history(self, arg):
818 """history [arg]: lists past commands issued 815 """history [arg]: lists past commands issued