summaryrefslogtreecommitdiff
path: root/docs/features/argument_processing.rst
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-11-08 19:17:53 -0500
committerGitHub <noreply@github.com>2019-11-08 19:17:53 -0500
commitd5916797620225391379ea40ae466bd7f496ff52 (patch)
tree6452dc4a3f1f45e31cfae16c8acccf3dd7746f14 /docs/features/argument_processing.rst
parenta18eef6f6aa89280b5f9b92d4e681f22a438ff8b (diff)
parent36796c2c6be67085f3d9000086de7052f08f433c (diff)
downloadcmd2-git-d5916797620225391379ea40ae466bd7f496ff52.tar.gz
Merge pull request #799 from python-cmd2/doc_updates
Doc updates
Diffstat (limited to 'docs/features/argument_processing.rst')
-rw-r--r--docs/features/argument_processing.rst24
1 files changed, 20 insertions, 4 deletions
diff --git a/docs/features/argument_processing.rst b/docs/features/argument_processing.rst
index a3d4a3aa..75d92c94 100644
--- a/docs/features/argument_processing.rst
+++ b/docs/features/argument_processing.rst
@@ -1,5 +1,3 @@
-.. _decorators:
-
Argument Processing
===================
@@ -33,6 +31,7 @@ applications.
.. _argprint: https://github.com/python-cmd2/cmd2/blob/master/examples/arg_print.py
.. _decorator: https://github.com/python-cmd2/cmd2/blob/master/examples/decorator_example.py
+.. _decorators:
Decorators provided by cmd2 for argument processing
---------------------------------------------------
@@ -40,12 +39,12 @@ Decorators provided by cmd2 for argument processing
``cmd2`` provides the following decorators for assisting with parsing arguments
passed to commands:
-.. automethod:: cmd2.decorators.with_argument_list
- :noindex:
.. automethod:: cmd2.decorators.with_argparser
:noindex:
.. automethod:: cmd2.decorators.with_argparser_and_unknown_args
:noindex:
+.. automethod:: cmd2.decorators.with_argument_list
+ :noindex:
All of these decorators accept an optional **preserve_quotes** argument which
defaults to ``False``. Setting this argument to ``True`` is useful for cases
@@ -342,3 +341,20 @@ use subcommands in your ``cmd2`` application.
.. _subcommands: https://github.com/python-cmd2/cmd2/blob/master/examples/subcommands.py
.. _tab_autocompletion: https://github.com/python-cmd2/cmd2/blob/master/examples/tab_autocompletion.py
+
+
+Argparse Extensions
+-------------------
+
+``cmd2`` augments the standard ``argparse.nargs`` with range tuple capability:
+
+- ``nargs=(5,)`` - accept 5 or more items
+- ``nargs=(8, 12)`` - accept 8 to 12 items
+
+``cmd2`` also provides the ``Cmd2ArgumentParser`` class which inherits from
+``argparse.ArgumentParser`` and improves error and help output:
+
+.. autoclass:: cmd2.argparse_custom.Cmd2ArgumentParser
+ :members:
+
+