summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-15 00:08:28 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-15 00:08:28 -0500
commitddac998671ed64c07af87feab7f3fd568bc76ce7 (patch)
treec8ad38ce555e18ec1193637adb509ff02a51fb03 /cmd2.py
parent0e77f4bf8d8e0ff73f7ff118c3780306d5f47f87 (diff)
downloadcmd2-git-ddac998671ed64c07af87feab7f3fd568bc76ce7.tar.gz
Fixed @with_argument_decorator so that built-in help text is preserved
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/cmd2.py b/cmd2.py
index 045f1a39..c8682dc5 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -258,6 +258,7 @@ def parse_quoted_string(cmdline):
lexed_arglist = temp_arglist
return lexed_arglist
+
def with_argument_parser(argparser):
"""A decorator to alter a cmd2 method to populate its ``opts``
argument by parsing arguments with the given instance of
@@ -293,6 +294,8 @@ def with_argument_list(func):
def cmd_wrapper(self, cmdline):
lexed_arglist = parse_quoted_string(cmdline)
func(self, lexed_arglist)
+
+ cmd_wrapper.__doc__ = func.__doc__
return cmd_wrapper
@@ -1672,6 +1675,7 @@ a..b, a:b, a:, ..b by indices (inclusive)
arg is string containing string
arg is /regex/ matching regular expression regex"""
argparser.add_argument('arg', nargs='*', help=_history_arg_help)
+
@with_argument_parser(argparser)
def do_history(self, arglist, args):
# If an argument was supplied, then retrieve partial contents of the history