Mercurial > python-cmd2
changeset 11:34107b79c840
working the refactor still
author | catherine@localhost |
---|---|
date | Thu, 15 May 2008 12:25:09 -0400 |
parents | 47af95ad83c7 |
children | b636cb715925 |
files | cmd2.py |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd2.py Thu May 15 12:21:38 2008 -0400 +++ b/cmd2.py Thu May 15 12:25:09 2008 -0400 @@ -23,9 +23,24 @@ import cmd, re, os, sys, optparse from optparse import make_option +class OptionParser(optparse.OptionParser): + def exit(self, status=0, msg=None): + if msg: + sys.stderr.write(msg) + + def error(self, msg): + """error(msg : string) + + Print a usage message incorporating 'msg' to stderr and exit. + If you override this in a subclass, it should not return -- it + should either exit or raise an exception. + """ + self.stderr.write(msg) + self.print_usage(sys.stderr) + def options(option_list): def option_setup(func): - optionParser = optparse.OptionParser() + optionParser = OptionParser() for opt in option_list: optionParser.add_option(opt) def newFunc(instance, arg):