Mercurial > python-cmd2
changeset 206:00eaec841567
do not let SET errors pass silently
author | catherine@dellzilla |
---|---|
date | Wed, 04 Mar 2009 16:45:41 -0500 |
parents | db4e8b2feb0c |
children | a3bec7704e65 |
files | cmd2.py |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd2.py Mon Mar 02 16:23:01 2009 -0500 +++ b/cmd2.py Wed Mar 04 16:45:41 2009 -0500 @@ -212,7 +212,7 @@ class Cmd(cmd.Cmd): echo = False caseInsensitive = True - continuationPrompt = '> ' + continuationprompt = '> ' timing = False legalChars = '!#$%.:?@_' + pyparsing.alphanums + pyparsing.alphas8bit # make sure your terminators are not in here! shortcuts = {'?': 'help', '!': 'shell', '@': 'load' } @@ -220,7 +220,7 @@ noSpecialParse = 'set ed edit exit'.split() defaultExtension = 'txt' defaultFileName = 'command.txt' - settable = ['prompt', 'continuationPrompt', 'defaultFileName', 'editor', 'caseInsensitive', + settable = ['prompt', 'continuationprompt', 'defaultFileName', 'editor', 'caseInsensitive', 'echo', 'timing'] settable.sort() @@ -519,7 +519,7 @@ statement = self.parsed(line) while statement.parsed.multilineCommand and (statement.parsed.terminator == ''): statement = '%s\n%s' % (statement.parsed.raw, - self.pseudo_raw_input(self.continuationPrompt)) + self.pseudo_raw_input(self.continuationprompt)) statement = self.parsed(statement) except Exception, e: print e @@ -651,11 +651,15 @@ do_eof = do_EOF def showParam(self, param): + any_shown = False param = param.strip().lower() for p in self.settable: if p.startswith(param): val = getattr(self, p) self.stdout.write('%s: %s\n' % (p, str(getattr(self, p)))) + any_shown = True + if not any_shown: + print "Parameter '%s' not supported (type 'show' for list of parameters)." % param def do_quit(self, arg): return self._STOP_AND_EXIT @@ -802,7 +806,7 @@ if fname is None: fname = self.defaultFileName fname = os.path.expanduser(fname) - keepstate = Statekeeper(self, ('stdin','use_rawinput','prompt','continuationPrompt')) + keepstate = Statekeeper(self, ('stdin','use_rawinput','prompt','continuationprompt')) if isinstance(fname, file): self.stdin = fname else: @@ -816,7 +820,7 @@ keepstate.restore() return self.use_rawinput = False - self.prompt = self.continuationPrompt = '' + self.prompt = self.continuationprompt = '' stop = self.cmdloop() self.stdin.close() keepstate.restore() @@ -988,8 +992,8 @@ line = self.transcript.next() command = [line[len(self.cmdapp.prompt):]] line = self.transcript.next() - while line.startswith(self.cmdapp.continuationPrompt): - command.append(line[len(self.cmdapp.continuationPrompt):]) + while line.startswith(self.cmdapp.continuationprompt): + command.append(line[len(self.cmdapp.continuationprompt):]) line = self.transcript.next() command = ''.join(command) self.cmdapp.onecmd(command)