summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorCatherine Devlin <catherine.devlin@gmail.com>2010-11-12 20:03:21 -0500
committerCatherine Devlin <catherine.devlin@gmail.com>2010-11-12 20:03:21 -0500
commitb8c399c79e560d963a7e0e4dbcfcf1b25c18a749 (patch)
tree929eb45b54121e7f648ebdc9eb716f81f59d1fa6 /cmd2.py
parent0a1a5f83a8586e50bdc48d6a102389a9c5a3e0ac (diff)
downloadcmd2-hg-b8c399c79e560d963a7e0e4dbcfcf1b25c18a749.tar.gz
added arg_desc to @options, thanks Renzo Crispiatico
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmd2.py b/cmd2.py
index beb2ce1..18bf9f3 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -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: