From ee9d0b388ac6e9d8a3f14bf73f1fcffa15aafd3c Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sun, 1 Sep 2024 12:15:19 +0200 Subject: [PATCH] feat: in structural commandline very is there is conflict alternative name --- src/rougail/structural_commandline/annotator.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/rougail/structural_commandline/annotator.py b/src/rougail/structural_commandline/annotator.py index 812eb082c..0b5d63c0a 100644 --- a/src/rougail/structural_commandline/annotator.py +++ b/src/rougail/structural_commandline/annotator.py @@ -30,6 +30,7 @@ class Annotator(Walk): def __init__(self, objectspace, *args) -> None: if not objectspace.paths: return + self.alternative_names = {} self.objectspace = objectspace not_for_commandlines = [] for family in self.get_families(): @@ -59,6 +60,17 @@ class Annotator(Walk): return alternative_name = variable.alternative_name variable_path = variable.path + all_letters = '' + for letter in alternative_name: + all_letters += letter + if all_letters == 'h': + msg = _(f'alternative_name "{alternative_name}" conflict with "--help"') + raise DictConsistencyError(msg, 202, variable.xmlfiles) + if all_letters in self.alternative_names: + msg = _(f'conflict alternative_name "{alternative_name}": "{variable_path}" and "{self.alternative_names[all_letters]}"') + raise DictConsistencyError(msg, 202, variable.xmlfiles) + + self.alternative_names[alternative_name] = variable_path if '.' not in variable_path: path = alternative_name else: @@ -71,7 +83,7 @@ class Annotator(Walk): raise DictConsistencyError(_(f'negative_description is mandatory for boolean variable, but "{variable.path}" hasn\'t'), 200, variable.xmlfiles) return if variable.type != 'boolean': - raise DictConsistencyError(_(f'negative_description is only available for boolean variable, but "{variable.path}" is "{variable.type}"'), 200, variable.xmlfiles) + raise DictConsistencyError(_(f'negative_description is only available for boolean variable, but "{variable.path}" is "{variable.type}"'), 201, variable.xmlfiles) self.objectspace.informations.add( variable.path, "negative_description", variable.negative_description )