comparison cmd2.py @ 84:416ea36af789 0.3.5

fixed bug in setting parameters
author catherine@Elli.myhome.westell.com
date Wed, 30 Jul 2008 11:06:22 -0400
parents 2176ce847939
children bd0adc37f3cc
comparison
equal deleted inserted replaced
83:2176ce847939 84:416ea36af789
9 Case-insensitive commands 9 Case-insensitive commands
10 Special-character shortcut commands (beyond cmd's "@" and "!") 10 Special-character shortcut commands (beyond cmd's "@" and "!")
11 Settable environment parameters 11 Settable environment parameters
12 Parsing commands with `optparse` options (flags) 12 Parsing commands with `optparse` options (flags)
13 Redirection to file with >, >>; input from file with < 13 Redirection to file with >, >>; input from file with <
14
15 Note that redirection with > and | will only work if `self.stdout.write()`
16 is used in place of `print`. The standard library's `cmd` module is
17 written to use `self.stdout.write()`,
14 18
15 - Catherine Devlin, Jan 03 2008 - catherinedevlin.blogspot.com 19 - Catherine Devlin, Jan 03 2008 - catherinedevlin.blogspot.com
16 20
17 CHANGES: 21 CHANGES:
18 As of 0.3.0, options should be specified as `optparse` options. See README.txt. 22 As of 0.3.0, options should be specified as `optparse` options. See README.txt.
425 paramName, val = arg.split(None, 1) 429 paramName, val = arg.split(None, 1)
426 paramName = self.clean(paramName) 430 paramName = self.clean(paramName)
427 if paramName not in self.settable: 431 if paramName not in self.settable:
428 raise NotSettableError 432 raise NotSettableError
429 currentVal = getattr(self, paramName) 433 currentVal = getattr(self, paramName)
430 val = cast(currentVal, val.strip(self.terminators)) 434 val = cast(currentVal, self.parsed(val).unterminated)
431 setattr(self, paramName, val) 435 setattr(self, paramName, val)
432 self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val)) 436 self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val))
433 except (ValueError, AttributeError, NotSettableError), e: 437 except (ValueError, AttributeError, NotSettableError), e:
434 self.do_show(arg) 438 self.do_show(arg)
435 439