diff options
| author | Catherine Devlin <catherine.devlin@gmail.com> | 2010-11-12 20:03:21 -0500 |
|---|---|---|
| committer | Catherine Devlin <catherine.devlin@gmail.com> | 2010-11-12 20:03:21 -0500 |
| commit | 2722a96a3bb2ac8282c7fe7d91fe7edd7c3e36e3 (patch) | |
| tree | 929eb45b54121e7f648ebdc9eb716f81f59d1fa6 /cmd2.py | |
| parent | 3082e8ad904a5384556fc5a4a9eda81c0004be32 (diff) | |
| download | cmd2-git-2722a96a3bb2ac8282c7fe7d91fe7edd7c3e36e3.tar.gz | |
added arg_desc to @options, thanks Renzo Crispiatico
Diffstat (limited to 'cmd2.py')
| -rwxr-xr-x | cmd2.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -97,7 +97,7 @@ optparse.Values.get = _attr_get_ options_defined = [] # used to distinguish --options from SQL-style --comments -def options(option_list): +def options(option_list, arg_desc="arg"): '''Used as a decorator and passed a list of optparse-style options, alters a cmd2 method to populate its ``opts`` argument from its raw text argument. @@ -107,7 +107,8 @@ def options(option_list): into @options([make_option('-q', '--quick', action="store_true", - help="Makes things fast")]) + help="Makes things fast")], + "source dest") def do_something(self, arg, opts): if opts.quick: self.fast_button = True @@ -120,7 +121,7 @@ def options(option_list): optionParser = OptionParser() for opt in option_list: optionParser.add_option(opt) - optionParser.set_usage("%s [options] arg" % func.__name__[3:]) + optionParser.set_usage("%s [options] %s" % (func.__name__[3:], arg_desc)) optionParser._func = func def new_func(instance, arg): try: |
