Issue #10772: add count and help argparse action; patch by Marc Sibson

This commit is contained in:
Sandro Tosi 2012-01-04 23:24:48 +01:00
parent 5fc58c6321
commit 8b211fc123
1 changed files with 13 additions and 0 deletions

View File

@ -703,6 +703,19 @@ how the command-line arguments should be handled. The supported actions are:
>>> parser.parse_args('--str --int'.split())
Namespace(types=[<type 'str'>, <type 'int'>])
* ``'count'`` - This counts the number of times a keyword argument occurs. For
example, this is useful for increasing verbosity levels::
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--verbose', '-v', action='count')
>>> parser.parse_args('-vvv'.split())
Namespace(verbose=3)
* ``'help'`` - This prints a complete help message for all the options in the
current parser and then exits. By default a help action is automatically
added to the parser. See :class:`ArgumentParser` for details of how the
output is created.
* ``'version'`` - This expects a ``version=`` keyword argument in the
:meth:`~ArgumentParser.add_argument` call, and prints version information
and exits when invoked.