python - How to customize "--help" with Click?
问题描述
Help messages in Click are accessed via the long option --help
by default. How can I also make the short option -h
available?
解决方案
Use context_settings
with help_option_names
:
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.command(context_settings=CONTEXT_SETTINGS)
def cli():
pass
This is straight out of the docs.
推荐阅读
- excel - 尝试在 VBA 中获取 API 数据的自动化错误
- javascript - 即使应用程序在后台,我如何每小时调用一个函数 - Cordova
- r - 语句 rm(list=ls()) 不会删除全局环境中的函数
- r - 基于节点删除或隐藏 iGraph 中的特定边
- sql - 子串?我可以使用此命令消除名称前的一些单词吗
- python - 如何将列添加到包含熊猫中列值对应的组名称的DataFrame
- java - 为什么 Feedly API 没有返回类别流中的所有 ids 条目?
- java - 春季启动资源getFile()不起作用
- docker - Yii 2 入门套件 - docker 在文件 .\.env 中:环境变量名称“YII_DEBUG”可能不包含空格。事件返回错误代码 1
- python - 仅当序列在 python 正则表达式中的另一个序列中具有相同数量的字符时,如何匹配特定的字符序列?