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

Documentation on how to implement --version flag #236

Open
smheidrich opened this issue Sep 24, 2024 · 0 comments
Open

Documentation on how to implement --version flag #236

smheidrich opened this issue Sep 24, 2024 · 0 comments
Assignees

Comments

@smheidrich
Copy link

Is your feature request related to a problem?

It's very common (almost mandatory) for CLI tools to provide a --version option which, when used, will just print the tool's version and exit. I couldn't find anything in argh's docs about how to best/most idiomatically implement this in (modern) argh.

Describe the solution you'd like

Somewhere in the docs there should be a short paragraph/example on how to implement best implement --version.

This might be a good candidate for the cookbook section of the docs if it's not a built-in feature (see last secion of this issue) and requires a bit of boilerplate.

Describe alternatives you've considered

  • Don't document it and let people come up with their own solutions.
  • Only document it once additional features that make it easier to implement have been added to argh (which ones?).

Additional context

argparse makes implementing this as easy1 as adding an argument with action="version". AFAIU, argh uses argparse under the hood and exposes it where possible, so maybe this can be leveraged?

1 Compare this to how it's how it's done in Typer... Although to be fair, Typer seeks to provide a generic mechanism instead of special-casing it like argparse does.

@smheidrich smheidrich changed the title Documentation about how to implement --version flag Documentation on how to implement --version flag Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants