Mercurial > python-cmd2
comparison cmd2/cmd2.py @ 103:e4daf715fc31
echo on
author | catherine@dellzilla |
---|---|
date | Tue, 14 Oct 2008 15:28:37 -0400 |
parents | 3de2a3eb765a |
children | bd91925d813c |
comparison
equal
deleted
inserted
replaced
102:5d241111b3d6 | 103:e4daf715fc31 |
---|---|
144 result = pyparsing.ParseResults('') | 144 result = pyparsing.ParseResults('') |
145 result['before'] = s | 145 result['before'] = s |
146 return result | 146 return result |
147 | 147 |
148 class Cmd(cmd.Cmd): | 148 class Cmd(cmd.Cmd): |
149 echo = False | |
149 caseInsensitive = True | 150 caseInsensitive = True |
150 multilineCommands = [] | 151 multilineCommands = [] |
151 continuationPrompt = '> ' | 152 continuationPrompt = '> ' |
152 shortcuts = {'?': 'help', '!': 'shell', '@': 'load'} | 153 shortcuts = {'?': 'help', '!': 'shell', '@': 'load'} |
153 excludeFromHistory = '''run r list l history hi ed edit li eof'''.split() | 154 excludeFromHistory = '''run r list l history hi ed edit li eof'''.split() |
161 else: | 162 else: |
162 for editor in ['gedit', 'kate', 'vim', 'emacs', 'nano', 'pico']: | 163 for editor in ['gedit', 'kate', 'vim', 'emacs', 'nano', 'pico']: |
163 if not os.system('which %s' % (editor)): | 164 if not os.system('which %s' % (editor)): |
164 break | 165 break |
165 | 166 |
166 settable = ['prompt', 'continuationPrompt', 'defaultFileName', 'editor', 'caseInsensitive'] | 167 settable = ['prompt', 'continuationPrompt', 'defaultFileName', 'editor', 'caseInsensitive', 'echo'] |
167 _TO_PASTE_BUFFER = 1 | 168 _TO_PASTE_BUFFER = 1 |
168 def do_cmdenvironment(self, args): | 169 def do_cmdenvironment(self, args): |
169 self.stdout.write(""" | 170 self.stdout.write(""" |
170 Commands are %(casesensitive)scase-sensitive. | 171 Commands are %(casesensitive)scase-sensitive. |
171 Commands may be terminated with: %(terminators)s | 172 Commands may be terminated with: %(terminators)s |
380 while not stop: | 381 while not stop: |
381 if self.cmdqueue: | 382 if self.cmdqueue: |
382 line = self.cmdqueue.pop(0) | 383 line = self.cmdqueue.pop(0) |
383 else: | 384 else: |
384 line = self.pseudo_raw_input(self.prompt) | 385 line = self.pseudo_raw_input(self.prompt) |
386 if (self.echo) and (isinstance(self.stdin, file)): | |
387 self.stdout.write(line + '\n') | |
385 line = self.precmd(line) | 388 line = self.precmd(line) |
386 stop = self.onecmd(line) | 389 stop = self.onecmd(line) |
387 stop = self.postcmd(stop, line) | 390 stop = self.postcmd(stop, line) |
388 self.postloop() | 391 self.postloop() |
389 finally: | 392 finally: |