# HG changeset patch # User catherine@localhost # Date 1210868709 14400 # Node ID 34107b79c840213642db375dccd168bfec96a76b # Parent 47af95ad83c7a72ae305fd18490935149943b28a working the refactor still diff -r 47af95ad83c7 -r 34107b79c840 cmd2.py --- 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):