diff options
author | kotfu <kotfu@kotfu.net> | 2018-01-07 20:02:38 -0700 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-01-07 20:02:38 -0700 |
commit | 6cb43c600f0b5d694201233ade6abd4f989d1730 (patch) | |
tree | c9acbeaf507a762db0b05b32a1e824b479279bfe /cmd2.py | |
parent | 8c58bb558adceb8ff32c7a3e1a88d2a13371dbfa (diff) | |
download | cmd2-git-6cb43c600f0b5d694201233ade6abd4f989d1730.tar.gz |
Set prog in argparser based on the name of the function
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 |