Open
Description
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:
main = CLI(short={}, parsers=...)
@main.cmd('open')
def open_(target: str, *paths: str):
...
@main.cmd
def close(target: str):
...
if __name__ == '__main__':
main()
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.
Metadata
Metadata
Assignees
Labels
No labels