python - 如何在 Fabric 中创建自定义帮助菜单?

标签 python fabric

当我运行fab --list时,我得到的输出为

error                        Call ``func`` with given error ``message``.
get_all_tags
get_head_position
get_latest_patch
get_latest_tag
get_pending_patches
glob                         Return a list of paths matching a pathname pattern.
handle_prompt_abort
help
indent                       Return ``text`` indented by the given number of spaces.

这包含几个用户定义的函数,例如 get_all_tags get_head_position 等,但没有任何说明。
我希望也包含这些函数的说明,以便我的列表看起来像这样

error                        Call ``func`` with given error ``message``.
get_all_tags                 Returns a list of all available tags
get_head_position            Returns the current Head position
get_latest_patch             Returns most recently created patch file name
get_latest_tag               Returns the most recent tags among all the tags
get_pending_patches          Returns list of all patches which are yet to be applied
glob                         Return a list of paths matching a pathname pattern.
handle_prompt_abort
help
indent                       Return ``text`` indented by the given number of spaces.

我该怎么做?

最佳答案

将文档字符串添加到函数中。

@task
def get_all_tags():
    "This is a docstring ..."

文档字符串用于显示帮助消息。

根据fab -l option documentation :

Imports a fabfile as normal, but then prints a list of all discovered tasks and exits. Will also print the first line of each task’s docstring, if it has one, next to it (truncating if necessary.)

关于python - 如何在 Fabric 中创建自定义帮助菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31724195/

相关文章:

python - Python中的两个同名函数

Python:如何写入 fd 3?

python - 安装 Steam 库时出现 PermissionError no 13

python - 对列表列表进行排序以查找共享变体

python - 我可以在一个项目目录中拥有多个 Python fabfile 吗?

python - 在沙盒 Pypy 中使用套接字模块

python - 在 Fabric 中使用网关时如何指定 pem 文件路径

python - 通过 Python/Fabric 从命令行更改 Unix 密码

python - 使用 atexit 进行织物清理操作

python - 结构错误 找不到记录器 "paramiko.transport"的处理程序