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 support for subcommands #102
Comments
@nicoulaj Thanks for this! Support for subcommands will get very quickly complex. I'm open to implementing something, but I want to make sure it's as simple and intuitive to grasp as possible -- otherwise, we might need to change the name of the library. 8^) Maybe can further discuss on the Google group -- I'd be interested to hear other opinions/proposals for tweaking the API to handle subcommands. |
@pholser yes, I understand your point. This is why I wanted to suggest something simple, but I already see some problems with this approach, for instance help will be poorly formatted. BTW I tried to join the Google group, but it's private. |
Nevermind, I can access it now. |
What about implementing subcommands as recursive sub-parsers? An It would be nicely modular, so it would be easy to add or edit a subcommand without affecting the remaining commands, even if there were redundant option names between them. |
Maybe similar to Python's It could be implemented as having a parser for each subcommands and a root parser that bundles them and just needs to evaluate the CLI arguments/flags until it encounters the sub command name/key. Then the sub command parser takes over. |
It looks from the comments in #49 that subcommands support has been considered at some point, but I am not sure what is the current status.
By subcommand support, I mean this type of syntax:
It seems to me it could be done without changing the whole API:
availableIf()
so that it can take an OptionSpec and a valueThis way we could use the API this way (pseudo-code):
Or maybe I am missing something in the API ?
The text was updated successfully, but these errors were encountered: