summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-01-22 16:15:41 -0500
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-01-22 16:15:41 -0500
commit4bdb20a1419f104637aecd5194c643a82412e035 (patch)
tree4f38e3195eead417e81312d7f56c6d7b995e38b3 /cmd2
parentb2c7113bc74c802bc8822dd1f0659339e8147380 (diff)
downloadcmd2-git-4bdb20a1419f104637aecd5194c643a82412e035.tar.gz
Removed with_argparser_and_unknown_args since it was deprecated in 1.3.0.
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/__init__.py3
-rw-r--r--cmd2/decorators.py43
2 files changed, 1 insertions, 45 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py
index f507dc28..a4bbfc41 100644
--- a/cmd2/__init__.py
+++ b/cmd2/__init__.py
@@ -30,8 +30,7 @@ from .argparse_custom import DEFAULT_ARGUMENT_PARSER
from .cmd2 import Cmd
from .command_definition import CommandSet, with_default_category
from .constants import COMMAND_NAME, DEFAULT_SHORTCUTS
-from .decorators import with_argument_list, with_argparser, with_argparser_and_unknown_args, with_category, \
- as_subcommand_to
+from .decorators import with_argument_list, with_argparser, with_category, as_subcommand_to
from .exceptions import Cmd2ArgparseError, CommandSetRegistrationError, CompletionError, SkipPostcommandHooks
from . import plugin
from .parsing import Statement
diff --git a/cmd2/decorators.py b/cmd2/decorators.py
index 6d99b848..f204bad9 100644
--- a/cmd2/decorators.py
+++ b/cmd2/decorators.py
@@ -188,49 +188,6 @@ def _set_parser_prog(parser: argparse.ArgumentParser, prog: str):
break
-def with_argparser_and_unknown_args(parser: argparse.ArgumentParser, *,
- ns_provider: Optional[Callable[..., argparse.Namespace]] = None,
- preserve_quotes: bool = False) -> \
- Callable[[argparse.Namespace, List], Optional[bool]]:
- """
- Deprecated decorator. Use `with_argparser(parser, with_unknown_args=True)` instead.
-
- 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 parser: unique instance of ArgumentParser
- :param ns_provider: An optional function that accepts a cmd2.Cmd object as an argument
- and returns an argparse.Namespace. This is useful if the Namespace
- needs to be prepopulated with state data that affects parsing.
- :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 :class:`cmd2.argparse_custom.Cmd2AttributeWrapper` called
- ``cmd2_statement`` is included in the ``Namespace`` to provide access to the :class:`cmd2.Statement`
- object. that was created when parsing the command line. This can be useful if the command function
- needs to know the command line.
-
- :Example:
-
- >>> parser = argparse.ArgumentParser()
- >>> parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
- >>> parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
- >>> parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
- >>>
- >>> class MyApp(cmd2.Cmd):
- >>> @cmd2.with_argparser(parser, with_unknown_args=True)
- >>> def do_argprint(self, args, unknown):
- >>> "Print the options and argument list this options command was called with."
- >>> self.poutput('args: {!r}'.format(args))
- >>> self.poutput('unknowns: {}'.format(unknown))
- """
- import warnings
- warnings.warn('This decorator will be deprecated. Use `with_argparser(parser, with_unknown_args=True)`.',
- PendingDeprecationWarning, stacklevel=2)
-
- return with_argparser(parser, ns_provider=ns_provider, preserve_quotes=preserve_quotes, with_unknown_args=True)
-
-
def with_argparser(parser: argparse.ArgumentParser, *,
ns_provider: Optional[Callable[..., argparse.Namespace]] = None,
preserve_quotes: bool = False,