Skip to content

Commit fc9a113

Browse files
committed
Closes #11807: document argparse add_subparsers method better.
Patch by Filip Gruszczyński.
1 parent c6a2c9b commit fc9a113

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

Doc/library/argparse.rst

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,10 @@ Other utilities
14521452
Sub-commands
14531453
^^^^^^^^^^^^
14541454

1455-
.. method:: ArgumentParser.add_subparsers()
1455+
.. method:: ArgumentParser.add_subparsers([title], [description], [prog], \
1456+
[parser_class], [action], \
1457+
[option_string], [dest], [help], \
1458+
[metavar])
14561459

14571460
Many programs split up their functionality into a number of sub-commands,
14581461
for example, the ``svn`` program can invoke sub-commands like ``svn
@@ -1466,6 +1469,30 @@ Sub-commands
14661469
command name and any :class:`ArgumentParser` constructor arguments, and
14671470
returns an :class:`ArgumentParser` object that can be modified as usual.
14681471

1472+
Description of parameters:
1473+
1474+
* title - title for the sub-parser group in help output; by default
1475+
"subcommands" if description is provided, otherwise uses title for
1476+
positional arguments
1477+
1478+
* description - description for the sub-parser group in help output, by
1479+
default None
1480+
1481+
* prog - usage information that will be displayed with sub-command help,
1482+
by default the name of the program and any positional arguments before the
1483+
subparser argument
1484+
1485+
* parser_class - class which will be used to create sub-parser instances, by
1486+
default the class of the current parser (e.g. ArgumentParser)
1487+
1488+
* dest - name of the attribute under which sub-command name will be
1489+
stored; by default None and no value is stored
1490+
1491+
* help - help for sub-parser group in help output, by default None
1492+
1493+
* metavar - string presenting available sub-commands in help; by default it
1494+
is None and presents sub-commands in form {cmd1, cmd2, ..}
1495+
14691496
Some example usage::
14701497

14711498
>>> # create the top-level parser

0 commit comments

Comments
 (0)