[英]How to customize the default help text for the command line python-fire by google?
I am trying to make a small command line tool using python-fire module by google .我正在尝试使用google 的 python-fire 模块制作一个小型命令行工具。 My filename is my_tools.py.我的文件名为 my_tools.py。 Inside my_tools.py I have code在 my_tools.py 里面我有代码
class MainFunction():
def __init__(self):
self.config = WrapperConfig()
def hey_world(self):
print("hey world")
if __name__ == '__main__':
fire.Fire(MainFunction)
When I run the command python my_tools.py in the terminal I get the Output as:当我在终端中运行命令 python my_tools.py 时,我得到 Output 作为:
NAME
my_tools.py
SYNOPSIS
my_tools.py GROUP | COMMAND
GROUPS
GROUP is one of the following:
config
COMMANDS
COMMAND is one of the following:
hey_world
Is there any way where I can customize this default help text?有什么方法可以自定义此默认帮助文本吗?
You can add docstring to the class and function.您可以将文档字符串添加到 class 和 function。
class MainFunction():
"""description of MainFunction"""
def __init__(self):
self.config = WrapperConfig()
def hey_world(self):
"""description of hey_world"""
print("hey world")
if __name__ == '__main__':
fire.Fire(MainFunction)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.