Repository: kedro-org/kedro
Issue category: Bug Report

Issue:
`kedro --version` isn't working 
## Description
Reported by @noklam, since adding lazy loading of Kedro subcommands, the `--version`/`-V` option isn't working. 

## Context
This bug is originating in Kedro 0.19.7 -> https://github.com/kedro-org/kedro/pull/3883


Hints:
> Usage: kedro [OPTIONS] COMMAND [ARGS]...
> Try 'kedro -h' for help.
> 
> Error: No such option: -v
> 

This is the stack trace when run `kedro -V`,  `kedro -v ` or `kedro --version`
While investgating this issue, I think it's worth checking why CI didn't catch this error, we have this test inplace.

```python
    def test_print_version(self):
        """Check that `kedro --version` and `kedro -V` outputs contain
        the current package version."""
        result = CliRunner().invoke(cli, ["--version"])

        assert result.exit_code == 0
        assert version in result.output
```
how to reproduce the error? the command works well for me
@DimedS  `kedro -V,r kedro --version` as mentioned. Are you using the `main` branch? Can you copy the terminal log when you do `kedro`?
I confirm `kedro -V` and `kedro --version` both give `No such option` errors with 0.19.9
I figured out what the problem is:
https://github.com/kedro-org/kedro/blob/a1fae5018f35243a5e49a54a9dd3223b2c4ea743/kedro/framework/cli/cli.py#L220

Due to the changes in lazy loading PR, I re-ordered the global commands list to consider 
- first the commands loaded from plugins, 
- then `cli` which is the group with `info` and the `version_option` decorator 
- and then the `global_commands` group which contains the `new` and `starter` lazy commands. 

So if any plugin with global commands (eg. Kedro-Viz) is installed in your env, the `--version` option doesn't work. It works when you uninstall Kedro viz. Which is why it must be working in the CI and for @DimedS 

The solution is simply to re-order the command groups to `[cli, *load_entry_points("global"), global_commands]` but that would mean that users can't overwrite `kedro info` which I think is acceptable.

Patch:
diff --git a/kedro/framework/cli/cli.py b/kedro/framework/cli/cli.py
index f5917e1b87..6ad4e24e97 100644
--- a/kedro/framework/cli/cli.py
+++ b/kedro/framework/cli/cli.py
@@ -217,7 +217,7 @@ def global_groups(self) -> Sequence[click.MultiCommand]:
         combines them with the built-in ones (eventually overriding the
         built-in ones if they are redefined by plugins).
         """
-        return [*load_entry_points("global"), cli, global_commands]
+        return [cli, *load_entry_points("global"), global_commands]
 
     @property
     def project_groups(self) -> Sequence[click.MultiCommand]:


Test patch: