Click: Ability to rename commands as separate from the method name

Created on 26 Jun 2014  路  3Comments  路  Source: pallets/click

Hi There!

I have a command named list in my click application.

@click.command()
def list():
    ...

I have another block of code in an unrelated function that uses the builtin list function.

self.PostFiles = list(reversed(sorted(listdir(self.config.posts))))

This throws an error because python calls the locally declared click method instead. Since I would like to keep "list" as the command name, the workaround I am using calls the ___builtin___.list() method directly where I need it, but this is ugly.

Is there a way we could implement a feature to rename the click command to something different from the method name?

All 3 comments

Set the name parameter on click.command to list and use a different
name for the function.

http://click.pocoo.org/api/?highlight=click.command#click.command

Also, please don't use the bugtracker as a support forum.

I'm sorry - I didn't know it was a feature already! Thanks for the prompt response.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rsyring picture rsyring  路  4Comments

ror6ax picture ror6ax  路  4Comments

rbonthond picture rbonthond  路  4Comments

dhstack picture dhstack  路  4Comments

arlyon picture arlyon  路  3Comments