diff options
author | Sandro Tosi <sandro.tosi@gmail.com> | 2012-01-04 22:25:04 (GMT) |
---|---|---|
committer | Sandro Tosi <sandro.tosi@gmail.com> | 2012-01-04 22:25:04 (GMT) |
commit | 98492a50ea30d2dffd7e16054e3aeb35cb2fed8d (patch) | |
tree | 03e06069f9ad15250ffab6f1dfae5a3a137728b1 /Doc/library/argparse.rst | |
parent | 6497aa3e00162752ebfae20e3e62a67e796d7630 (diff) | |
download | cpython-98492a50ea30d2dffd7e16054e3aeb35cb2fed8d.zip cpython-98492a50ea30d2dffd7e16054e3aeb35cb2fed8d.tar.gz cpython-98492a50ea30d2dffd7e16054e3aeb35cb2fed8d.tar.bz2 |
Issue #10772: add count and help argparse action; patch by Marc Sibson
Diffstat (limited to 'Doc/library/argparse.rst')
-rw-r--r-- | Doc/library/argparse.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 12684db..28537e9 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -705,6 +705,19 @@ how the command-line arguments should be handled. The supported actions are: >>> parser.parse_args('--str --int'.split()) Namespace(types=[<class 'str'>, <class '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. |