首页 > 解决方案 > 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?

标签: pythonpython-click

解决方案


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.


推荐阅读