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

interest in passing functions, not strings for commands? #195

Open
bmc-msft opened this issue Apr 14, 2020 · 1 comment
Open

interest in passing functions, not strings for commands? #195

bmc-msft opened this issue Apr 14, 2020 · 1 comment
Assignees

Comments

@bmc-msft
Copy link

Having found myself frustrated with argparse, I started looking into Knack for argument parsing.

One of the choices that I'm wondering about in Knack is the choice to specify the command groups with strings, which when used are passed to import_module & a python version independent inspect to get the implementation of the command.

This makes it difficult to use static analysis to verify code using this module, since it's roughly akin to eval.

Additionally, it makes it difficult to programmatically generate a CLI from classes, as it requires going from object instance back to strings for the module and function paths.

Is there any interest in supporting functions rather than strings?

Something akin to:

with CommandGroup(self, "hello") as g:
    g.command("world", hello_world_handler)
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 14, 2020

@jiasli please take a look

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

No branches or pull requests

3 participants