-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add a registry class #105
Comments
This seems reasonable modulo API bikeshedding, but I will not have the bandwidth to consider all the options at least for the coming month(s). But I'll keep this open for later. |
One question, though, is how you propose to handle subcommands in this API. Perhaps |
Using that pattern in Click and argparse, I find those then become a maze of indirection through a module. One alternative would be to avoid creating the intermediate objects with partially bound state and just allow the decorators to accept the path where a function will be exposed: @main.command('project', 'new')
def new_project():
print("creating new project")
|
Agreed that Do you want to try your hand at proposing a PR? :-) |
I really like the fact that defopt works without mandatory decorators.
But, practically, I find myself repeatedly writing some small utility that allows using decorators to register subcommands to pass into
defopt.run()
. My most recent one looks like this:The decorator serves as an annotation about which functions are exposed as CLI subcommands, which is handy in a longer file where many of the functions are not exposed.
I think an optional registration utility like this would be a handy thing for defopt to have.
The text was updated successfully, but these errors were encountered: