diff options
| author | kotfu <kotfu@kotfu.net> | 2020-02-10 16:05:57 -0700 |
|---|---|---|
| committer | kotfu <kotfu@kotfu.net> | 2020-02-10 16:05:57 -0700 |
| commit | 2c4207f4ee12bf22c1ba7d7300554dedf6d53909 (patch) | |
| tree | c922405c37a7c7b9143cbad24866f9109cd4849e /cmd2 | |
| parent | 508014ab9860c7dcd7c9530793ebdb71cde6e5f2 (diff) | |
| download | cmd2-git-2c4207f4ee12bf22c1ba7d7300554dedf6d53909.tar.gz | |
Add example to with_argument_list docstring
Diffstat (limited to 'cmd2')
| -rw-r--r-- | cmd2/decorators.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/cmd2/decorators.py b/cmd2/decorators.py index 2c812345..f46e1423 100644 --- a/cmd2/decorators.py +++ b/cmd2/decorators.py @@ -31,12 +31,22 @@ def with_category(category: str) -> Callable: def with_argument_list(*args: List[Callable], preserve_quotes: bool = False) -> Callable[[List], Optional[bool]]: - """A decorator to alter the arguments passed to a do_* cmd2 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. + """ + A decorator to alter the arguments passed to a ``do_*`` 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. - :param args: Single-element positional argument list containing do_* method this decorator is wrapping + :param args: Single-element positional argument list containing do_* method + this decorator is wrapping :param preserve_quotes: if True, then argument quotes will not be stripped :return: function that gets passed a list of argument strings + + :Example: + + >>> class MyApp(cmd2.Cmd): + >>> @cmd2.with_argument_list + >>> def do_echo(self, arglist): + >>> self.poutput(' '.join(arglist) """ import functools |
