diff options
author | Georg Brandl <georg@python.org> | 2013-10-06 16:51:39 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-10-06 16:51:39 (GMT) |
commit | 1f94b26cbafa25713051fc2f5dbc2c7fedb13d20 (patch) | |
tree | aa621b1d3584793832a3b3198099aa0f999511ce | |
parent | c0edadee84ea87c1b0f8eb3bfe26a023d303bb4a (diff) | |
download | cpython-1f94b26cbafa25713051fc2f5dbc2c7fedb13d20.zip cpython-1f94b26cbafa25713051fc2f5dbc2c7fedb13d20.tar.gz cpython-1f94b26cbafa25713051fc2f5dbc2c7fedb13d20.tar.bz2 |
Closes #11807: document argparse add_subparsers method better.
Patch by Filip GruszczyĆski.
-rw-r--r-- | Doc/library/argparse.rst | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index a1d58c0..28ecee9 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1432,7 +1432,10 @@ Other utilities Sub-commands ^^^^^^^^^^^^ -.. method:: ArgumentParser.add_subparsers() +.. method:: ArgumentParser.add_subparsers([title], [description], [prog], \ + [parser_class], [action], \ + [option_string], [dest], [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 @@ -1446,6 +1449,30 @@ Sub-commands command name and any :class:`ArgumentParser` constructor arguments, and returns an :class:`ArgumentParser` object that can be modified as usual. + Description of parameters: + + * title - title for the sub-parser group in help output; by default + "subcommands" if description is provided, otherwise uses title for + positional arguments + + * description - description for the sub-parser group in help output, by + default None + + * prog - usage information that will be displayed with sub-command help, + by default the name of the program and any positional arguments before the + subparser argument + + * parser_class - class which will be used to create sub-parser instances, by + default the class of the current parser (e.g. ArgumentParser) + + * dest - name of the attribute under which sub-command name will be + stored; by default None and no value is stored + + * help - help for sub-parser group in help output, by default None + + * metavar - string presenting available sub-commands in help; by default it + is None and presents sub-commands in form {cmd1, cmd2, ..} + Some example usage:: >>> # create the top-level parser |