Mercurial > python-cmd2
comparison cmd2.py @ 296:ae476b714190
tolerate single option in non-list form
author | catherine@bothari |
---|---|
date | Sun, 24 Jan 2010 07:42:41 -0500 |
parents | f5593299fc2a |
children | ab340dfd2e14 |
comparison
equal
deleted
inserted
replaced
295:f5593299fc2a | 296:ae476b714190 |
---|---|
100 help="Makes things fast")]) | 100 help="Makes things fast")]) |
101 def do_something(self, arg, opts): | 101 def do_something(self, arg, opts): |
102 if opts.quick: | 102 if opts.quick: |
103 self.fast_button = True | 103 self.fast_button = True |
104 ''' | 104 ''' |
105 if not isinstance(option_list, list): | |
106 option_list = [option_list] | |
105 def option_setup(func): | 107 def option_setup(func): |
106 optionParser = OptionParser() | 108 optionParser = OptionParser() |
107 for opt in option_list: | 109 for opt in option_list: |
108 optionParser.add_option(opt) | 110 optionParser.add_option(opt) |
109 optionParser.set_usage("%s [options] arg" % func.__name__.strip('do_')) | 111 optionParser.set_usage("%s [options] arg" % func.__name__.strip('do_')) |