无论何时使用单击创建命令或组,都会有一个默认的--help
选项来显示使用指南:
import click
@click.command()
def main():
click.echo('Success!')
if __name__ == '__main__':
main()
如果我使用--help
运行文件,我应该得到:
$ python file.py --help
Usage: file.py [OPTIONS]
Options:
--help Show this message and exit.
现在,单击允许您通过decorator中的参数覆盖通过终端调用help
选项的方式:
@click.command(
context_settings=dict(
help_option_names=['-f', '--foo']
)
)
def main():
click.echo('Success!')
$ python file.py -f
Usage: file.py [OPTIONS]
Options:
-f, --foo Show this message and exit.
然而,翻阅Click的documentation,我看不到类似的选项来覆盖默认的帮助message.
是否有一个参数指定为click.command
,在终端中调用帮助时覆盖文本"Show this message and exit"?