Skip to content

Documentation on how to implement --version flag #236

@smheidrich

Description

@smheidrich

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions