Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version flag alongside other commands #468

Open
amin-nejad opened this issue Oct 11, 2023 · 3 comments
Open

Version flag alongside other commands #468

amin-nejad opened this issue Oct 11, 2023 · 3 comments

Comments

@amin-nejad
Copy link

I have a script which has multiple commands, each of which have their own arguments etc. I would like to add a simple flag to be used standalone to simply display the version of my script. I would like the the --help display to additionally show users this flag is available without affecting the other commands. For instance if my script is called foo, I'd like to be able to do:

foo --version or foo -v

but I'd still like to do:

foo mycommand myarg etc.

The two closest solutions I've tried each have a downside:

  • the flags and the commands are displayed in different help windows e.g. foo --help shows the help window for the flags whilst foo standlone shows the help window for the commands
  • the help window shows both flags and commands but the flag is interpreted as a flag to the commands such that if I type foo --version, the version is displayed but so is the help window because it thinks a command is missing

I'm using fire==0.5.0. Is there any way I can achieve this?

@jfrost-mo
Copy link

The short option should be -V, as -v is usually short for verbose.

Otherwise this would be a great feature, as command --version is a very common pattern on CLI programs for testing if it is installed correctly.

@dbieber
Copy link
Member

dbieber commented Dec 12, 2023

Right now foo --version is not supported but foo -- --version is. The reason we originally chose not to support foo --version is that the function foo could have an argument named version, and in that case it would be a name collision.

@dbieber
Copy link
Member

dbieber commented Dec 12, 2023

I would be supportive of a change that makes foo --version in addition to foo -- --version in all cases except where --version is an acceptable flag to foo. However, note that such a change is not currently planned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants