我在本地模块中使用点击,我想调整帮助的显示方式:
当前输出--help
:
Usage: __main__.py [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
foo Foo is a program very nice and pretty...
默认情况下,prog
名称是__main__.py
,文本被修剪为 78 个字符。
我发现这可以使用HelpFormatter
类进行调整。但我不知道如何在这种情况下使用它。
当前代码:
import click
@click.group()
def main(ctx):
pass
@main.command()
def foo():
pass
click.CommandCollection(sources=[main])()
预期输出:
Usage: my_module_name [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
foo Foo is a program very nice and pretty and this sentence is very long.