]> Savannah Git Hosting - gnulib.git/commitdiff
parser: fix verbosity option
authorDmitry Selyutin <ghostmansd@gmail.com>
Wed, 20 Sep 2017 08:12:40 +0000 (11:12 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Wed, 20 Sep 2017 08:12:40 +0000 (11:12 +0300)
pygnulib/parser.py

index ad5d247f0a9d554e6416cfd836e78353320128b3..9ac06619d3023967fde533b92fc97830625886a7 100644 (file)
@@ -183,15 +183,19 @@ class CommandLine:
             super().__call__(*args)
 
 
-    class _VerbosityAction_(_Option_):
+    class _VerbosityOption_(_Option_):
+        def __init__(self, *args, **kwargs):
+            super().__init__(nargs=0, *args, **kwargs)
+
+
         def __call__(self, parser, namespace, value, option=None):
-            args = (parser, namespace, value, option)
             if not hasattr(namespace, self.dest):
                 setattr(namespace, self.dest, 0)
             value = getattr(namespace, self.dest)
             verbose = option in ("-v", "--verbose")
             value += +1 if verbose else -1
             setattr(namespace, self.dest, value)
+            args = (parser, namespace, value, option)
             super().__call__(*args)
 
 
@@ -436,14 +440,14 @@ class CommandLine:
                     "help": (
                         "increase verbosity; may be repeated",
                     ),
-                    "action": _VerbosityAction_,
+                    "action": _VerbosityOption_,
                     "dest": "verbosity",
                 }),
                 (["-q", "--quiet"], {
                     "help": (
                         "decrease verbosity; may be repeated",
                     ),
-                    "action": _VerbosityAction_,
+                    "action": _VerbosityOption_,
                     "dest": "verbosity",
                 }),
             ),