summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2017-09-20 21:35:27 (GMT)
committerÉric Araujo <merwok@users.noreply.github.com>2017-09-20 21:35:27 (GMT)
commitaaf6fc0982c916cb71d9e0afcd7dda4ba495793b (patch)
tree09cb0078fade182a8be0a108bb50b57a71156bd9 /Doc/library
parent19e4d9346db7fb65845b98a9cb9caacaaac8a81a (diff)
downloadcpython-aaf6fc0982c916cb71d9e0afcd7dda4ba495793b.zip
cpython-aaf6fc0982c916cb71d9e0afcd7dda4ba495793b.tar.gz
cpython-aaf6fc0982c916cb71d9e0afcd7dda4ba495793b.tar.bz2
bpo-26510: make argparse subparsers required by default (#3027)
This fixes a regression from Python 2. To get optional subparsers, use the new parameter ``add_subparsers(required=False)``. Patch by Anthony Sottile.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/argparse.rst7
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index c425be6..53e6701 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1539,8 +1539,8 @@ Sub-commands
.. method:: ArgumentParser.add_subparsers([title], [description], [prog], \
[parser_class], [action], \
- [option_string], [dest], [help], \
- [metavar])
+ [option_string], [dest], [required] \
+ [help], [metavar])
Many programs split up their functionality into a number of sub-commands,
for example, the ``svn`` program can invoke sub-commands like ``svn
@@ -1576,6 +1576,9 @@ Sub-commands
* dest_ - name of the attribute under which sub-command name will be
stored; by default ``None`` and no value is stored
+ * required_ - Whether or not a subcommand must be provided, by default
+ ``True``.
+
* help_ - help for sub-parser group in help output, by default ``None``
* metavar_ - string presenting available sub-commands in help; by default it