summaryrefslogtreecommitdiff
path: root/docs/argument_processing.rst
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-20 18:04:43 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-20 18:04:43 -0500
commitbd948d727e0e13fa5fd77199c06fcd3dfdda9b39 (patch)
treebbb7ae35cb76becccddfe7dd4258c87b2c463b68 /docs/argument_processing.rst
parent5550ab73a91d2834e6bda72eb3889998ad59be51 (diff)
downloadcmd2-git-bd948d727e0e13fa5fd77199c06fcd3dfdda9b39.tar.gz
Added unit tests for newly-overridden complete() method
Also added a section on Sub-commands to the documentation.
Diffstat (limited to 'docs/argument_processing.rst')
-rw-r--r--docs/argument_processing.rst13
1 files changed, 11 insertions, 2 deletions
diff --git a/docs/argument_processing.rst b/docs/argument_processing.rst
index cc08e4e5..98d622bc 100644
--- a/docs/argument_processing.rst
+++ b/docs/argument_processing.rst
@@ -166,14 +166,14 @@ The default behavior of ``cmd2`` is to pass the user input directly to your
Using the argument parser decorator and also receiving a a list of unknown positional arguments
===============================================================================================
If you want all unknown arguments to be passed to your command as a list of strings, then
-decorate the command method with the ``@with_argparser_and_list`` decorator.
+decorate the command method with the ``@with_argparser_and_unknown_args`` decorator.
Here's what it looks like::
dir_parser = argparse.ArgumentParser()
dir_parser.add_argument('-l', '--long', action='store_true', help="display in long format with one item per line")
- @with_argparser_and_list(dir_parser)
+ @with_argparser_and_unknown_args(dir_parser)
def do_dir(self, args, unknown):
"""List contents of current directory."""
# No arguments for this command
@@ -188,6 +188,15 @@ Here's what it looks like::
...
+Sub-commands
+============
+Sub-commands are supported for commands using either the ``@with_argument_parser`` or
+``@with_argparser_and_unknown_args`` decorator. The syntax for supporting them is based on argparse sub-parsers.
+
+See the subcommands_ example to learn more about how to use sub-commands in your ``cmd2`` application.
+
+.. _subcommands: https://github.com/python-cmd2/cmd2/blob/master/examples/subcommands.py
+
Deprecated optparse support
===========================