summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-02-27 08:49:26 -0500
committerGitHub <noreply@github.com>2018-02-27 08:49:26 -0500
commit41c5484c3d198ceba9115710e79082790ab40a08 (patch)
treefedd8e33ea308e8b732dc3efa43c4d1ffbfc77eb /cmd2.py
parent656a7742f0f15bf64f259e4f32b1d0a082fcfc83 (diff)
parentc40a96291b4c97685122d6840f14d324f17fe88f (diff)
downloadcmd2-git-41c5484c3d198ceba9115710e79082790ab40a08.tar.gz
Merge pull request #283 from python-cmd2/functools_wraps
Added use of @functools.wraps() in our decorators
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/cmd2.py b/cmd2.py
index 1c2daf7b..cd2d9d54 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -30,6 +30,7 @@ import cmd
import codecs
import collections
import datetime
+import functools
import glob
import io
import optparse
@@ -271,6 +272,7 @@ def with_argument_list(func):
method. Default passes a string of whatever the user typed.
With this decorator, the decorated method will receive a list
of arguments parsed from user input using shlex.split()."""
+ @functools.wraps(func)
def cmd_wrapper(self, cmdline):
lexed_arglist = parse_quoted_string(cmdline)
func(self, lexed_arglist)
@@ -288,6 +290,7 @@ def with_argparser_and_unknown_args(argparser, subcommand_names=None):
:return: function that gets passed parsed args and a list of unknown args
"""
def arg_decorator(func):
+ @functools.wraps(func)
def cmd_wrapper(instance, cmdline):
lexed_arglist = parse_quoted_string(cmdline)
args, unknown = argparser.parse_known_args(lexed_arglist)
@@ -324,6 +327,7 @@ def with_argparser(argparser, subcommand_names=None):
:return: function that gets passed parsed args
"""
def arg_decorator(func):
+ @functools.wraps(func)
def cmd_wrapper(instance, cmdline):
lexed_arglist = parse_quoted_string(cmdline)
args = argparser.parse_args(lexed_arglist)
@@ -387,6 +391,7 @@ def options(option_list, arg_desc="arg"):
option_parser.set_usage("%s %s" % (func.__name__[3:], arg_desc))
option_parser._func = func
+ @functools.wraps(func)
def new_func(instance, arg):
"""For @options commands this replaces the actual do_* methods in the instance __dict__.