[英]Python click, Can you make -h as an alias
I have recently found the click library ( http://click.pocoo.org/6/ ) and I love it. 我最近找到了点击库( http://click.pocoo.org/6/ ),我喜欢它。
I am trying to figure out if it is possible to create an alias for the --help
option which shortcuts to the help. 我试图弄清楚是否可以为
--help
选项创建一个别名,该选项是帮助的快捷方式。 So, for example: 所以,例如:
app.py --help
gives the help for the main app and 为主应用程序提供帮助
app.py sub --help
will give the help for the sub. 将为sub提供帮助。 I want to be able to use -h as well.
我希望能够使用-h。 If I were creating the option, it may look something like:
如果我正在创建选项,它可能看起来像:
@click.option('-h', '--help')
but the --help
option is built in. Is there a way to extend that option or create an alias for it? 但是
--help
选项是内置的。有没有办法扩展该选项或为它创建别名?
Well, I found it: 好吧,我找到了:
https://click.palletsprojects.com/en/7.x/documentation/#help-parameter-customization https://click.palletsprojects.com/en/7.x/documentation/#help-parameter-customization
@click.command(context_settings=dict(help_option_names=["-h", "--help"]))
def cli():
pass
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.