18

I have recently found the click library (http://click.pocoo.org/6/) and I love it.

I am trying to figure out if it is possible to create an alias for the --help option which shortcuts to the 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. I want to be able to use -h as well. 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?

Timofei Bondarev
  • 158
  • 3
  • 12
Jeff
  • 4,285
  • 15
  • 63
  • 115

1 Answers1

29

Well, I found it:

https://click.palletsprojects.com/en/7.x/documentation/#help-parameter-customization

@click.command(context_settings=dict(help_option_names=["-h", "--help"]))
def cli():
    pass
anatoly techtonik
  • 19,847
  • 9
  • 124
  • 140
Jeff
  • 4,285
  • 15
  • 63
  • 115