summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-01-07 20:02:38 -0700
committerkotfu <kotfu@kotfu.net>2018-01-07 20:02:38 -0700
commit6cb43c600f0b5d694201233ade6abd4f989d1730 (patch)
treec9acbeaf507a762db0b05b32a1e824b479279bfe /cmd2.py
parent8c58bb558adceb8ff32c7a3e1a88d2a13371dbfa (diff)
downloadcmd2-git-6cb43c600f0b5d694201233ade6abd4f989d1730.tar.gz
Set prog in argparser based on the name of the function
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd2.py b/cmd2.py
index c284a66f..f5c1dab0 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -260,13 +260,17 @@ def with_argument_parser(argparser):
opts = argparser.parse_args(lexed_arglist)
func(instance, arg, opts)
+ # argparser defaults the program name to sys.argv[0]
+ # we want it to be the name of our command
+ argparser.prog = func.__name__[3:]
+
+ # put the help message in the method docstring
funcdoc = func.__doc__
if funcdoc:
funcdoc += '\n'
else:
# if it's None, make it an empty string
funcdoc = ''
-
cmd_wrapper.__doc__ = '{}{}'.format(funcdoc, argparser.format_help())
return cmd_wrapper
return arg_decorator