You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks to all the developers for bringing click python package to everyone. It's an amazing package and makes building command line tools a breeze. I've been using click for quite sometime and always recommend others too.
Recently I stumbled up on a task, which is to add --version option for package(main) and sub packages. This is my first time working on custom groups. We've created a custom group class and added list_commands() and get_command() methods to get sub packages commands.
I did look into version_option decorator, but I don't think I can add a decorator to the custom group class. So, I've added the --version option in the custom group class __init__() method:
and add invoke() method to the TestGroup class, which gets the version info from version_option decorator, but it throws error saying this command doesn't have a name attribute.
I understand I'm doing it wrong, but not sure how to proceed it. Can you guide me. Thanks
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Thanks to all the developers for bringing click python package to everyone. It's an amazing package and makes building command line tools a breeze. I've been using click for quite sometime and always recommend others too.
Recently I stumbled up on a task, which is to add
--version
option for package(main) and sub packages. This is my first time working on custom groups. We've created a custom group class and addedlist_commands()
andget_command()
methods to get sub packages commands.click - v7.x
python - v3.9
Following is what we've used for reference
https://click.palletsprojects.com/en/7.x/commands/#custom-multi-commands
I did look into
version_option
decorator, but I don't think I can add a decorator to the custom group class. So, I've added the--version
option in the custom group class__init__()
method:and add
invoke()
method to the TestGroup class, which gets the version info fromversion_option
decorator, but it throws error saying this command doesn't have a name attribute.I understand I'm doing it wrong, but not sure how to proceed it. Can you guide me. Thanks
Beta Was this translation helpful? Give feedback.
All reactions