summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-05-14 18:42:22 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-05-14 18:42:22 -0400
commitfff34d20d37a4e8329dbaf10cfd0cb4e08621806 (patch)
treea04b7b816048874e1b453cc7cc4201454b3610b9 /cmd2/cmd2.py
parent366c309fc4f3eb3474d8d4241440026ed86a83cf (diff)
downloadcmd2-git-fff34d20d37a4e8329dbaf10cfd0cb4e08621806.tar.gz
Changed order of function arguments
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 824ebc63..c20205c7 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -192,16 +192,16 @@ def with_argument_list(*args: List[Callable], preserve_quotes: bool = False) ->
def with_argparser_and_unknown_args(argparser: argparse.ArgumentParser,
- ns_provider: Optional[Callable[[None], argparse.Namespace]] = None,
- preserve_quotes: bool = False) -> \
+ preserve_quotes: bool = False,
+ ns_provider: Optional[Callable[[None], argparse.Namespace]] = None,) -> \
Callable[[argparse.Namespace, List], Optional[bool]]:
"""A decorator to alter a cmd2 method to populate its ``args`` argument by parsing arguments with the given
instance of argparse.ArgumentParser, but also returning unknown args as a list.
:param argparser: unique instance of ArgumentParser
+ :param preserve_quotes: if True, then arguments passed to argparse maintain their quotes
:param ns_provider: an optional function that provides the Namespace for parse_known_args().
this is useful if the Namespace needs to be prepopulated based on instance data.
- :param preserve_quotes: if True, then arguments passed to argparse maintain their quotes
:return: function that gets passed argparse-parsed args in a Namespace and a list of unknown argument strings
A member called __statement__ is added to the Namespace to provide command functions access to the
Statement object. This can be useful if the command function needs to know the command line.
@@ -251,15 +251,16 @@ def with_argparser_and_unknown_args(argparser: argparse.ArgumentParser,
def with_argparser(argparser: argparse.ArgumentParser,
- ns_provider: Optional[Callable[[None], argparse.Namespace]] = None,
- preserve_quotes: bool = False) -> Callable[[argparse.Namespace], Optional[bool]]:
+ preserve_quotes: bool = False,
+ ns_provider: Optional[Callable[[None], argparse.Namespace]] = None) -> \
+ Callable[[argparse.Namespace], Optional[bool]]:
"""A decorator to alter a cmd2 method to populate its ``args`` argument by parsing arguments
with the given instance of argparse.ArgumentParser.
:param argparser: unique instance of ArgumentParser
+ :param preserve_quotes: if True, then arguments passed to argparse maintain their quotes
:param ns_provider: an optional function that provides the Namespace for parse_args().
this is useful if the Namespace needs to be prepopulated based on instance data.
- :param preserve_quotes: if True, then arguments passed to argparse maintain their quotes
:return: function that gets passed the argparse-parsed args in a Namespace
A member called __statement__ is added to the Namespace to provide command functions access to the
Statement object. This can be useful if the command function needs to know the command line.