comparison cmd2.py @ 11:34107b79c840

working the refactor still
author catherine@localhost
date Thu, 15 May 2008 12:25:09 -0400
parents 47af95ad83c7
children b636cb715925
comparison
equal deleted inserted replaced
10:47af95ad83c7 11:34107b79c840
21 - Catherine Devlin, Jan 03 2008 - catherinedevlin.blogspot.com 21 - Catherine Devlin, Jan 03 2008 - catherinedevlin.blogspot.com
22 """ 22 """
23 import cmd, re, os, sys, optparse 23 import cmd, re, os, sys, optparse
24 from optparse import make_option 24 from optparse import make_option
25 25
26 class OptionParser(optparse.OptionParser):
27 def exit(self, status=0, msg=None):
28 if msg:
29 sys.stderr.write(msg)
30
31 def error(self, msg):
32 """error(msg : string)
33
34 Print a usage message incorporating 'msg' to stderr and exit.
35 If you override this in a subclass, it should not return -- it
36 should either exit or raise an exception.
37 """
38 self.stderr.write(msg)
39 self.print_usage(sys.stderr)
40
26 def options(option_list): 41 def options(option_list):
27 def option_setup(func): 42 def option_setup(func):
28 optionParser = optparse.OptionParser() 43 optionParser = OptionParser()
29 for opt in option_list: 44 for opt in option_list:
30 optionParser.add_option(opt) 45 optionParser.add_option(opt)
31 def newFunc(instance, arg): 46 def newFunc(instance, arg):
32 optionParser.set_usage("%s [options] arg" % func.__name__) 47 optionParser.set_usage("%s [options] arg" % func.__name__)
33 try: 48 try: