summaryrefslogtreecommitdiff
path: root/docs/features/argument_processing.rst
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-08-25 12:03:49 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-08-25 12:03:49 -0400
commit5942f2105eb83140a8ab37e655e2561c4d17d3a2 (patch)
tree09f6a2a6da8a0da4c8150b84988f41ad571312f6 /docs/features/argument_processing.rst
parenta394ed3b83be17986e168b8d0817892cbabd088f (diff)
parent97c348c599d8fa963553593e5c19fb100b85e313 (diff)
downloadcmd2-git-5942f2105eb83140a8ab37e655e2561c4d17d3a2.tar.gz
Merge branch 'master' into 2.0
Diffstat (limited to 'docs/features/argument_processing.rst')
-rw-r--r--docs/features/argument_processing.rst18
1 files changed, 17 insertions, 1 deletions
diff --git a/docs/features/argument_processing.rst b/docs/features/argument_processing.rst
index 9e65742e..7ce8c815 100644
--- a/docs/features/argument_processing.rst
+++ b/docs/features/argument_processing.rst
@@ -14,7 +14,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``.
+ the ``Namespace`` and can also be retrieved by calling ``get_statement()``
+ on the ``Namespace``.
4. Adds the usage message from the argument parser to your command.
@@ -382,3 +383,18 @@ fashion.
.. _decorator_primer: https://realpython.com/primer-on-python-decorators
.. _help_categories: https://github.com/python-cmd2/cmd2/blob/master/examples/help_categories.py
+
+
+Reserved Argument Names
+-----------------------
+``cmd2`` argparse decorators add the following attributes to argparse
+Namespaces. To avoid naming collisions, do not use any of the names for your
+argparse arguments.
+
+- ``__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