google / google/python-fire

Version flag alongside other commands

Abierto
#468 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
28.2k
Forks
1.5k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.