Python Click Command Names

I am using a click package to create a command line tool. However, I would like to have a list command. For instance:

@click.command @click.option(help='list...') def list(): # do stuff here 

Is there any other way to click to pass a command name other than a function name? I do not want this function to be poked by python built in to list . I looked through the documentation and cannot find anything about the command names - I read the command aliases, but this does not seem to help this problem. Or do I need to worry about the list being obscured as it will be wrapped in click decor? Thank you in advance.

+5
source share
1 answer

You can specify the name argument when using the command decorator. When you do this, you can name your function as you want:

 @click.command(name='list') def list_command(): pass 

For more information, see the documentation .

+10
source

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


All Articles