cleo icon indicating copy to clipboard operation
cleo copied to clipboard

Make `--version` a non-global option?

Open mkniewallner opened this issue 3 years ago • 1 comments

As reported in https://github.com/python-poetry/poetry/issues/5128, --version is currently a global option in cleo.

This makes the behavior of some commands pretty weird, since passing --version to any command will exit the command early and print the version.

For instance, in the case of Poetry:

$ poetry add httpx --version
Poetry (version 1.2.0b2.dev0)

This also prevents this option from being used for commands in other contexts, as the original issue in Poetry reports.

Proposal

As this is still nice to have --version option, maybe the option could only be available for the default command? That way, in the case of Poetry, doing either poetry --version or poetry list --version would display the version, but poetry add httpx --version would raise The option "--version" does not exist, and in the future, we would be able to add --version for specific commands if needed.

Though this proposal would definitely be a breaking change worth mentioning.

mkniewallner avatar May 28 '22 09:05 mkniewallner

This may be controversial, but I would propose going further and moving all global arguments before the command.

Today poetry's documented usage is poetry command [options] [arguments], maybe instead the pattern should be poetry [options] command [arguments].

The current approach is problematic because it doesn't allow tasks from plugins to accept any of the same options as poetry. My motivating example here is in the poethepoet poetry plugin, where firstly the poe CLI accepts some of the same options as poetry (although most can be made to work seamlessly), but more importantly poe tasks (which are configured by the user) should ideally be able to accept any options without them being intercepted by poetry.

nat-n avatar Feb 23 '25 20:02 nat-n