Fixed verbosity levels bigger than 1.

Partially my fault and also a bug in docopt.
This commit is contained in:
Salvador E. Tropea 2020-07-28 23:09:33 -03:00
parent 9d3645fa41
commit 956cba7c98
2 changed files with 11 additions and 3 deletions

View File

@ -6,7 +6,7 @@ Usage:
[-q | -v...] [-i] [TARGET...] [-q | -v...] [-i] [TARGET...]
kiplot [-c PLOT_CONFIG] --list kiplot [-c PLOT_CONFIG] --list
kiplot [-b BOARD] [-d OUT_DIR] [-p | -P] --example kiplot [-b BOARD] [-d OUT_DIR] [-p | -P] --example
kiplot [-v] --help-list-outputs kiplot [-v...] --help-list-outputs
kiplot --help-output=HELP_OUTPUT kiplot --help-output=HELP_OUTPUT
kiplot --help-outputs kiplot --help-outputs
kiplot --help-preflights kiplot --help-preflights

View File

@ -8,11 +8,13 @@
""" """
import sys import sys
import re import re
from copy import deepcopy
__all__ = ['docopt'] __all__ = ['docopt']
__version__ = '0.6.2' __version__ = '0.6.2'
# Define to True if countable args can match to different counts in different patterns
safe_outcomes = False
class DocoptLanguageError(Exception): class DocoptLanguageError(Exception):
@ -273,7 +275,13 @@ class Either(BranchPattern):
for pattern in self.children: for pattern in self.children:
matched, _, _ = outcome = pattern.match(left, collected) matched, _, _ = outcome = pattern.match(left, collected)
if matched: if matched:
outcomes.append(outcome) # If a counter argument is used in two patterns and the limit of counts is different for
# each pattern you risk to match different counters.
# By copying the result we avoid the risk.
if safe_outcomes:
outcomes.append(deepcopy(outcome))
else:
outcomes.append(outcome)
if outcomes: if outcomes:
return min(outcomes, key=lambda outcome: len(outcome[1])) return min(outcomes, key=lambda outcome: len(outcome[1]))
return False, left, collected return False, left, collected