python单击返回帮助器菜单 [英] python Click Return the helper menu
问题描述
我刚刚开始使用python click模块,我希望它可以在单击引发错误时自动调出'--help'功能.
I just started using python click module and I would like to have it automatically bring up the '--help' function anytime click throws an error.
test.py
@click.command()
@click.option('--count', default=1, help='Number of greetings.')
@click.option('--name', default=Adam,
help='The person to great.')
def test(name):
print name
如果要从命令行以test.py --no_such_thing的身份运行脚本.有没有办法我可以得到--help而不是正常的帮助 :Error no Option --no_such_thing
If I was to run the script from the command line as test.py --no_such_thing. Is there a way I could get the --help to come up instead of the normal :Error no Option --no_such_thing
推荐答案
简而言之,您需要修改方法click.exceptions.UsageError.show
.
但是,我在
In short, you need to modify the method click.exceptions.UsageError.show
.
But, I have posted a more in-depth answer to this question, along with sample code, in the answer to this SO post.
这篇关于python单击返回帮助器菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!