From 30e27b12f50acedc529e951cd12b836d78aca7c2 Mon Sep 17 00:00:00 2001 From: Valentin Volkl Date: Fri, 30 Jan 2026 16:20:04 +0100 Subject: [PATCH 1/2] Case-insensitive CLI options --- easybuild/base/generaloption.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/easybuild/base/generaloption.py b/easybuild/base/generaloption.py index b2b4c7c06c..bbeb72db0b 100644 --- a/easybuild/base/generaloption.py +++ b/easybuild/base/generaloption.py @@ -135,6 +135,25 @@ def check_str_list_tuple(option, opt, value): # pylint: disable=unused-argument else: return klass(split) +def check_choice_case_insensitive(option, opt, value): + """ + Case-insensitive check function for choice type. + Performs case-insensitive matching against available choices. + Returns the properly-cased choice value from the choices list. + """ + # Create a mapping from lowercase choices to original choices + choices_map = {choice.lower(): choice for choice in option.choices} + + value_lower = value.lower() + if value_lower in choices_map: + # Return the properly-cased choice from the original choices list + return choices_map[value_lower] + else: + choices = ", ".join(map(repr, option.choices)) + raise OptionValueError( + _gettext("option %s: invalid choice: %r (choose from %s)") + % (opt, value, choices)) + def get_empty_add_flex(allvalues, self=None): """Return the empty element for add_flex action for allvalues""" @@ -215,6 +234,8 @@ class ExtOption(CompleterOption): TYPE_CHECKER.update(Option.TYPE_CHECKER) TYPES = tuple(TYPE_STRLIST + list(Option.TYPES)) BOOLEAN_ACTIONS = ('store_true', 'store_false',) + EXTOPTION_LOG + # Override the choice checker to be case-insensitive + TYPE_CHECKER['choice'] = check_choice_case_insensitive def __init__(self, *args, **kwargs): """Add logger to init""" From 20f75cdffde51a042867361cea56059db09d55d3 Mon Sep 17 00:00:00 2001 From: Valentin Volkl Date: Fri, 30 Jan 2026 16:23:01 +0100 Subject: [PATCH 2/2] fix whitespace --- easybuild/base/generaloption.py | 1 + 1 file changed, 1 insertion(+) diff --git a/easybuild/base/generaloption.py b/easybuild/base/generaloption.py index bbeb72db0b..7123c92f13 100644 --- a/easybuild/base/generaloption.py +++ b/easybuild/base/generaloption.py @@ -135,6 +135,7 @@ def check_str_list_tuple(option, opt, value): # pylint: disable=unused-argument else: return klass(split) + def check_choice_case_insensitive(option, opt, value): """ Case-insensitive check function for choice type.