]> granicus.if.org Git - python/commitdiff
Issue #10772: add count and help argparse action; patch by Marc Sibson
authorSandro Tosi <sandro.tosi@gmail.com>
Wed, 4 Jan 2012 22:25:04 +0000 (23:25 +0100)
committerSandro Tosi <sandro.tosi@gmail.com>
Wed, 4 Jan 2012 22:25:04 +0000 (23:25 +0100)
Doc/library/argparse.rst

index 12684dbb8b1b7fc514769bb8fba8aa02d4885b8b..28537e938c58fcb333ba7aec14831c812a298b53 100644 (file)
@@ -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.