Repository: kedro-org/kedro

Issue:
Allow ranges and individual values in the add-ons selection
## Description
Should we allow users to enter selections in this format - `1,2,4-7`
![Screenshot 2023-11-23 at 11 16 08](https://github.com/kedro-org/kedro/assets/110245118/c21f9689-a168-4735-98d8-beec7dbe99de)



Discussion:

Resolving patch:
diff --git a/kedro/framework/cli/starters.py b/kedro/framework/cli/starters.py
--- a/kedro/framework/cli/starters.py
+++ b/kedro/framework/cli/starters.py
@@ -758,11 +758,19 @@ def _validate_config_file_inputs(config: dict[str, str]):
 
     input_tools = config.get("tools", "none")
     tools_validation_config = {
-        "regex_validator": r"^(all|none|(( )*\d*(,\d*)*(,( )*\d*)*( )*|( )*((\d+-\d+)|(\d+ - \d+))( )*))$",
+        "regex_validator": r"""^(
+            all|none|                        # A: "all" or "none" or
+            (\ *\d+                          # B: any number of spaces followed by one or more digits
+            (\ *-\ *\d+)?                    # C: zero or one instances of: a hyphen followed by one or more digits, spaces allowed
+            (\ *,\ *\d+(\ *-\ *\d+)?)*       # D: any number of instances of: a comma followed by B and C, spaces allowed
+            \ *)?)                           # E: zero or one instances of (B,C,D) as empty strings are also permissible
+            $""",
         "error_message": f"'{input_tools}' is an invalid value for project tools. Please select valid options for tools using comma-separated values, ranges, or 'all/none'.",
     }
 
-    if not re.match(tools_validation_config["regex_validator"], input_tools.lower()):
+    if not re.match(
+        tools_validation_config["regex_validator"], input_tools.lower(), flags=re.X
+    ):
         message = tools_validation_config["error_message"]
         click.secho(message, fg="red", err=True)
         sys.exit(1)


Test patch:
diff --git a/tests/framework/cli/test_starters.py b/tests/framework/cli/test_starters.py
--- a/tests/framework/cli/test_starters.py
+++ b/tests/framework/cli/test_starters.py
@@ -967,8 +967,14 @@ class TestToolsAndExampleFromUserPrompts:
             "6",
             "7",
             "none",
+            "",
             "2,3,4",
             "3-5",
+            "1,2,4-6",
+            "1,2,4-6,7",
+            "4-6,7",
+            "1, 2 ,4 - 6, 7",
+            "1-3, 5-7",
             "all",
             "1, 2, 3",
             "  1,  2, 3  ",
@@ -991,7 +997,7 @@ def test_valid_tools_and_example(self, fake_kedro_cli, tools, example_pipeline):
 
     @pytest.mark.parametrize(
         "bad_input",
-        ["bad input", "-1", "3-"],
+        ["bad input", "-1", "3-", "1 1"],
     )
     def test_invalid_tools(self, fake_kedro_cli, bad_input):
         result = CliRunner().invoke(
@@ -1079,8 +1085,14 @@ class TestToolsAndExampleFromConfigFile:
             "6",
             "7",
             "none",
+            "",
             "2,3,4",
             "3-5",
+            "1,2,4-6",
+            "1,2,4-6,7",
+            "4-6,7",
+            "1, 2 ,4 - 6, 7",
+            "1-3,5-7",
             "all",
             "1, 2, 3",
             "  1,  2, 3  ",
@@ -1108,7 +1120,7 @@ def test_valid_tools_and_example(self, fake_kedro_cli, tools, example_pipeline):
 
     @pytest.mark.parametrize(
         "bad_input",
-        ["bad input", "-1", "3-"],
+        ["bad input", "-1", "3-", "1 1"],
     )
     def test_invalid_tools(self, fake_kedro_cli, bad_input):
         """Test project created from config."""