diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-08-27 13:19:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 13:19:23 -0400 |
commit | f4943a904efba05c13eb930b4a4535c19429c72c (patch) | |
tree | cbaff855e2d73f1d86ae1230f32770e31c62ad6b /docs/features | |
parent | 97c348c599d8fa963553593e5c19fb100b85e313 (diff) | |
parent | 478ea83336a4d1659ad06ef365db3dc5e051e46d (diff) | |
download | cmd2-git-f4943a904efba05c13eb930b4a4535c19429c72c.tar.gz |
Merge pull request #985 from python-cmd2/dynamic_value
Added Cmd2AttributeWrapper class
Diffstat (limited to 'docs/features')
-rw-r--r-- | docs/features/argument_processing.rst | 20 | ||||
-rw-r--r-- | docs/features/modular_commands.rst | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/docs/features/argument_processing.rst b/docs/features/argument_processing.rst index 7ce8c815..06f48f82 100644 --- a/docs/features/argument_processing.rst +++ b/docs/features/argument_processing.rst @@ -13,9 +13,8 @@ handles the following for you: 3. Passes the resulting ``argparse.Namespace`` object to your command function. The ``Namespace`` includes the ``Statement`` object that was created when - parsing the command line. It is stored in the ``__statement__`` attribute of - the ``Namespace`` and can also be retrieved by calling ``get_statement()`` - on the ``Namespace``. + parsing the command line. It can be retrieved by calling + ``cmd2_statement.get()`` on the ``Namespace``. 4. Adds the usage message from the argument parser to your command. @@ -391,10 +390,13 @@ Reserved Argument Names Namespaces. To avoid naming collisions, do not use any of the names for your argparse arguments. +- ``cmd2_statement`` - ``cmd2.Cmd2AttributeWrapper`` object containing + ``cmd2.Statement`` object that was created when parsing the command line. - ``__statement__`` - ``cmd2.Statement`` object that was created when parsing - the command line. -- ``get_statement()`` - convenience function which returns the ``Statement`` -- ``__subcmd_handler__`` - points to subcommand handler function. This is added - when using the ``@cmd2.as_subcommand_to`` decorator. -- ``get_handler()`` - convenience function which returns the subcommand handler - or ``None`` if one was not set + the command line. (This is deprecated and will be removed in 2.0.0.) Use + ``cmd2_statement`` instead. + +- ``__subcmd_handler__`` - used by cmd2 to identify the handler for a + subcommand created with ``@cmd2.as_subcommand_to`` decorator. +- ``cmd2_handler`` - ``cmd2.Cmd2AttributeWrapper`` object containing + a subcommand handler function or ``None`` if one was not set. diff --git a/docs/features/modular_commands.rst b/docs/features/modular_commands.rst index dddd996e..4abeda2d 100644 --- a/docs/features/modular_commands.rst +++ b/docs/features/modular_commands.rst @@ -316,7 +316,7 @@ command and each CommandSet @with_argparser(cut_parser) def do_cut(self, ns: argparse.Namespace): - handler = ns.get_handler() + handler = ns.cmd2_handler.get() if handler is not None: # Call whatever subcommand function was selected handler(ns) |