Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decorators to annotate functions as commmands #135

Open
anirban1c opened this issue Jan 13, 2019 · 2 comments
Open

decorators to annotate functions as commmands #135

anirban1c opened this issue Jan 13, 2019 · 2 comments

Comments

@anirban1c
Copy link

something like

@command
@argument('--id', type=int, help='My name', desc='ID of some kind')
@argument('--name', type=str, help='My name', desc='is my name')
createRecord(id, name):
`...

@tjprescott
Copy link
Member

Hi @anirban1c thank you for the suggestion. The Azure CLI was originally written using just such decorators, but we fould it didn't scale well and maintenance was extremely tedious. At least in Azure CLI, many commands had the common arguments with the common metadata, which mean I needed a dozen lines of extra decorator code per command, and if I wanted to update the help text for all the commands, I had to update it in multiple places.

That is the basis for the argument registries in Knack, which follow the DRY principle and avoid all the decorator boilerplate.

@anirban1c
Copy link
Author

am surprised decorators didnt scale ? partials, functools and decorators are legends ! thats what attracted me to python :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants