google / google/python-fire

Multiline docstring in help with parameters and their descriptions

Abierto
#181 7 comentarios 5 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'm using the [latest version](https://github.com/google/python-fire/commit/024fbad9424cfdb0d3c93c86c856aedbac0f9d48) of Fire as of now and was wondering if it's possible to display a multiline docstring in help instead of concatenating it to one line. Also is there a way of displaying the available params and their descriptions in the help screen?

Example program:
```python
# main.py
import fire

class MyCLI:
def create(name, surname):
"""
Method to create a user \n
And some second line to describe some specific cases.
And some third line that could be concatenated with the second one
:param name name of the user
:param surname surname of the user
:raises ValueError if user with this name and surname already exist
:returns: unique id of the created user
"""
...

def remove(id):
"""
Removes user given the id
:id unique id to identify the user
:raises ValueError if there is no user with the specified id
"""
...

if __name__ == '__main__':
cli = MyCLI()
fire.Fire(cli)
```

Expected help:
```bash
main.py -h

NAME
main.py -

SYNOPSIS
main.py COMMAND

COMMANDS
COMMAND is one of the following:

create
Method to create a user
And some second line to describe some specific cases. And some third line that could be concatenated with the second one

remove
Removes user given the id
```

Example command help (more specific)
```bash
main.py create -h

NAME
main.py create - Method to create a user

SYNOPSIS
main.py create NAME SURNAME

DESCRIPTION
Method to create a user
And some second line to describe some specific cases. And some third line that could be concatenated with the second one
--name: name of the user
--surname: surname of the user
raises ValueError if user with this name and surname already exist
returns: unique id of the created user

POSITIONAL ARGUMENTS
NAME
SURNAME

NOTES
You can also use flags syntax for POSITIONAL ARGUMENTS
```

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.