comparison cmd2.py @ 12:b636cb715925

tested
author catherine@localhost
date Thu, 15 May 2008 12:42:01 -0400
parents 34107b79c840
children c6e8b645c0ab
comparison
equal deleted inserted replaced
11:34107b79c840 12:b636cb715925
41 def options(option_list): 41 def options(option_list):
42 def option_setup(func): 42 def option_setup(func):
43 optionParser = OptionParser() 43 optionParser = OptionParser()
44 for opt in option_list: 44 for opt in option_list:
45 optionParser.add_option(opt) 45 optionParser.add_option(opt)
46 optionParser.set_usage("%s [options] arg" % func.__name__.strip('do_'))
46 def newFunc(instance, arg): 47 def newFunc(instance, arg):
47 optionParser.set_usage("%s [options] arg" % func.__name__)
48 try: 48 try:
49 opts, arg = optionParser.parse_args(arg.split()) 49 opts, arg = optionParser.parse_args(arg.split())
50 except optparse.OptionValueError, e: 50 except optparse.OptionValueError, e:
51 print e 51 print e
52 optionParser.print_help() 52 optionParser.print_help()