diff --git a/easybuild/tools/options.py b/easybuild/tools/options.py index b4b729ab0c..793e9e7704 100644 --- a/easybuild/tools/options.py +++ b/easybuild/tools/options.py @@ -96,6 +96,13 @@ class EasyBuildOptions(GeneralOption): ALLOPTSMANDATORY = False # allow more than one argument CONFIGFILES_RAISE_MISSING = True # don't allow non-existing config files to be specified + # don't allow passing of values that are look very similar to an existing option (due to a typo) + # require to use --longopt=value instead to remove ambiguity and unexpected behaviour due to small typos + ALLOW_OPTION_NAME_AS_VALUE = False # exact match for option name (without the '-') as value + ALLOW_OPTION_AS_VALUE = False # exact match for option as value + ALLOW_DASH_AS_VALUE = False # any value starting with a '-' + ALLOW_TYPO_AS_VALUE = False # value with similarity score from difflib.get_close_matches + def __init__(self, *args, **kwargs): """Constructor.""" diff --git a/setup.py b/setup.py index 13800b9f51..f5516753e1 100644 --- a/setup.py +++ b/setup.py @@ -107,5 +107,5 @@ def find_rel_test(): provides=["eb"] + easybuild_packages, test_suite="test.framework.suite", zip_safe=False, - install_requires=["vsc-base >= 2.2.4"], + install_requires=["vsc-base >= 2.4.1"], ) diff --git a/test/framework/options.py b/test/framework/options.py index 7f10003976..95847f0f47 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -49,7 +49,7 @@ from easybuild.tools.filetools import mkdir, read_file, write_file from easybuild.tools.github import fetch_github_token from easybuild.tools.modules import modules_tool -from easybuild.tools.options import EasyBuildOptions +from easybuild.tools.options import EasyBuildOptions, parse_options from easybuild.tools.toolchain.utilities import TC_CONST_PREFIX from easybuild.tools.version import VERSION from vsc.utils import fancylogger @@ -1898,6 +1898,13 @@ def test_review_pr(self): self.mock_stdout(False) self.assertTrue(re.search(r"^Comparing zlib-1.2.8\S* with zlib-1.2.8", txt)) + def test_allow_values_that_are_probably_meant_to_be_options(self): + """Test detecting typos or ambiguities on the eb command line.""" + common_args = [] + + eb_go = parse_options(args=common_args + ['-r', 'f']) + self.assertFalse('f' in eb_go.options.robot) + def suite(): """ returns all the testcases in this module """