Repository: kedro-org/kedro
File: kedro/framework/cli/starters.py (Python)

Code before:
        KedroCliError: If it fails to generate a project.
    """
    # noqa: import-outside-toplevel
    from cookiecutter.main import cookiecutter  # for performance reasons

    try:
        result_path = cookiecutter(template=template_path, **cookiecutter_args)
    except Exception as exc:
        raise KedroCliError(
            "Failed to generate project when running cookiecutter."
        ) from exc

    _clean_pycache(Path(result_path))
    extra_context = cookiecutter_args["extra_context"]
    project_name = extra_context.get("project_name", "New Kedro Project")
    tools = extra_context.get("tools")
    example_pipeline = extra_context.get("example_pipeline")

    click.secho(
        "\nCongratulations!"
        f"\nYour project '{project_name}' has been created in the directory \n{result_path}\n"
    )

    # End here if a starter was used
    if template_path != TEMPLATE_PATH:
        return

    if tools is not None:
        if tools == "['None']":
            click.secho(
                "You have selected no project tools",
                fg="green",
            )
        else:
            click.secho(
                f"You have selected the following project tools: {tools}",
                fg="green",
            )

    if example_pipeline is not None:
        if example_pipeline:
            click.secho(
                "It has been created with an example pipeline.",
                fg="green",
            )


class _Prompt:
    """Represent a single CLI prompt for `kedro new`"""

    def __init__(self, *args, **kwargs) -> None:  # noqa: unused-argument

Review comment (suggestion):
Removed the comment as the string to list conversion is done later in the execution timeline, and the final item stored in `pyproject.toml` is indeed a list object. This conversion cannot happen before the cookiecutter generation, as `cookiecutter` does not store lists but rather parses them as a selection of options, only storing one of the values within the list. 

Code after:
            click.secho(message, fg="red", err=True)
            sys.exit(1)


def _parse_tools_input(tools_str: str | None):
    """Parse the tools input string.

    Args:
        tools_str: Input string from prompts.yml.

    Returns:
        list: List of selected tools as strings.
    """

    def _validate_range(start, end):
        if int(start) > int(end):
            message = f"'{start}-{end}' is an invalid range for project tools.\nPlease ensure range values go from smaller to larger."
            click.secho(message, fg="red", err=True)
            sys.exit(1)

    if not tools_str:
        return []  # pragma: no cover

    tools_str = tools_str.lower()
    if tools_str == "all":
        return list(NUMBER_TO_TOOLS_NAME)
    if tools_str == "none":
        return []

    # Split by comma
    tools_choices = tools_str.replace(" ", "").split(",")
    selected: list[str] = []

    for choice in tools_choices:
        if "-" in choice:
            start, end = choice.split("-")
            _validate_range(start, end)
            selected.extend(str(i) for i in range(int(start), int(end) + 1))
        else:
            selected.append(choice.strip())

    return selected


def _create_project(template_path: str, cookiecutter_args: dict[str, Any]):
    """Creates a new kedro project using cookiecutter.

    Args:
        template_path: The path to the cookiecutter template to create the project.
            It could either be a local directory or a remote VCS repository
            supported by cookiecutter. For more details, please see: