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

Code before:
            _validate_config_file(key)
        ctx.default_map.update(config)

    return value


def _validate_config_file(key):
    """Validate the keys provided in the config file against the accepted keys."""
    accepted_keys = [
        "from_inputs",
        "to_outputs",
        "from_nodes",
        "to_nodes",
        "node_names",
        "runner",
        "env",
        "tags",
        "load_versions",
        "pipeline",
        "namespace",
        "conf_source",
        "params",
        "is_async",
        "tag",
        "nodes_names",
        "load_version",
    ]
    if key not in accepted_keys:
        message = _suggest_cli_command(key, accepted_keys)
        raise KedroCliError(
            f"Key `{key}` in provided configuration is not valid. {message}"
        )


def _reformat_load_versions(ctx, param, value) -> dict[str, str]:
    """Reformat data structure from tuple to dictionary for `load-version`, e.g.:
    ('dataset1:time1', 'dataset2:time2') -> {"dataset1": "time1", "dataset2": "time2"}.
    """
    if param.name == "load_version":
        _deprecate_options(ctx, param, value)

    load_versions_dict = {}
    for load_version in value:
        load_version = load_version.strip()  # noqa: PLW2901
        load_version_list = load_version.split(":", 1)
        if len(load_version_list) != 2:  # noqa: PLR2004
            raise KedroCliError(
                f"Expected the form of 'load_version' to be "
                f"'dataset_name:YYYY-MM-DDThh.mm.ss.sssZ',"
                f"found {load_version} instead"
            )

Review comment (suggestion):
```
from kedro.framework.cli.project import run

# Inspect arguments
args = [click_arg.name for click_arg in run.params]
print(args)
```

(need to remove `config` from the list)

I played around with it you can retrieve the argument list of a click command.

Code after:
    """

    ctx.default_map = ctx.default_map or {}
    section = ctx.info_name

    if value:
        config = OmegaConf.to_container(OmegaConf.load(value))[section]
        for key, value in config.items():
            _validate_config_file(key)
        ctx.default_map.update(config)

    return value


def _validate_config_file(key):
    """Validate the keys provided in the config file against the accepted keys."""
    from kedro.framework.cli.project import run

    run_args = [click_arg.name for click_arg in run.params]
    run_args.remove("config")
    if key not in run_args:
        KedroCliError.VERBOSE_EXISTS = False
        message = _suggest_cli_command(key, run_args)
        raise KedroCliError(
            f"Key `{key}` in provided configuration is not valid. {message}"
        )


def _split_params(ctx, param, value):
    if isinstance(value, dict):
        return value
    dot_list = []
    for item in split_string(ctx, param, value):
        equals_idx = item.find("=")
        colon_idx = item.find(":")
        if equals_idx != -1 and colon_idx != -1 and equals_idx < colon_idx:
            # For cases where key-value pair is separated by = and the value contains a colon
            # which should not be replaced by =
            pass
        else:
            item = item.replace(":", "=", 1)  # noqa: PLW2901
        items = item.split("=", 1)
        if len(items) != 2:  # noqa: PLR2004
            ctx.fail(
                f"Invalid format of `{param.name}` option: "
                f"Item `{items[0]}` must contain "
                f"a key and a value separated by `:` or `=`."
            )
        key = items[0].strip()
        if not key:
            ctx.fail(