Python click, can you do -h as an alias

I recently found a click library ( http://click.pocoo.org/6/ ) and I like it.

I am trying to figure out if it is possible to create an alias for the --help parameter, which contains help shortcuts. So for example:

 app.py --help 

provides assistance for the main application and

 app.py sub --help 

will provide assistance for sub. I want to use -h too. If I created this parameter, it might look something like this:

 @click.option('-h', '--help') 

but the --help option is built in. Is there a way to expand this setting or create an alias for it?

+8
source share
1 answer

Well, I found

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

 @click.command(context_settings=dict(help_option_names=["-h", "--help"])) def cli(): pass 
+12
source

Source: https://habr.com/ru/post/1237763/


All Articles