Mercurial > python-cmd2
diff cmd2.py @ 209:6dc79bf15fc6
trying move of shortcut expansion
author | catherine@dellzilla |
---|---|
date | Tue, 10 Mar 2009 09:48:04 -0400 |
parents | f10bd1f0c7e3 |
children | 3f8fac776845 |
line wrap: on
line diff
--- a/cmd2.py Mon Mar 09 20:48:20 2009 -0400 +++ b/cmd2.py Tue Mar 10 09:48:04 2009 -0400 @@ -482,10 +482,12 @@ p = raw else: s = self.inputParser.transformString(raw.lstrip()) + ''' for (shortcut, expansion) in self.shortcuts.items(): if s.lower().startswith(shortcut): s = s.replace(shortcut, expansion + ' ', 1) break + ''' result = self.parser.parseString(s) result['command'] = result.multilineCommand or result.command result['raw'] = raw @@ -512,6 +514,10 @@ """ if not line: return self.emptyline() + for (shortcut, expansion) in self.shortcuts.items(): + if line.lower().lstrip().startswith(shortcut): + line = line.replace(shortcut, expansion + ' ', 1) + break if not pyparsing.Or(self.commentGrammars).setParseAction(lambda x: '').transformString(line): return 0 # command was empty except for comments try: