comparison cmd2.py @ 356:d275d3beceff

fix usage help name-stripping bug
author catherine@dellzilla
date Wed, 17 Feb 2010 14:32:04 -0500
parents 5972ae04515e
children 4530fc11d743
comparison
equal deleted inserted replaced
355:5972ae04515e 356:d275d3beceff
118 options_defined.append(pyparsing.Literal(opt.get_opt_string())) 118 options_defined.append(pyparsing.Literal(opt.get_opt_string()))
119 def option_setup(func): 119 def option_setup(func):
120 optionParser = OptionParser() 120 optionParser = OptionParser()
121 for opt in option_list: 121 for opt in option_list:
122 optionParser.add_option(opt) 122 optionParser.add_option(opt)
123 optionParser.set_usage("%s [options] arg" % func.__name__.strip('do_')) 123 optionParser.set_usage("%s [options] arg" % func.__name__[3:])
124 optionParser._func = func 124 optionParser._func = func
125 def new_func(instance, arg): 125 def new_func(instance, arg):
126 try: 126 try:
127 opts, newArgList = optionParser.parse_args(arg.split()) 127 opts, newArgList = optionParser.parse_args(arg.split())
128 # Must find the remaining args in the original argument list, but 128 # Must find the remaining args in the original argument list, but