google / google/python-fire

Multiline docstring in help with parameters and their descriptions

未关闭
#181 7 条评论 5 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
28.2k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

描述

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
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。