-
Notifications
You must be signed in to change notification settings - Fork 71
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
Current API seems inconsistent #45
Comments
Now you also can use nested subcommands. I didn't get what you can't do now. Could you describe a problem with current approach? |
Is it possible to describe cli options like
|
|
Oh, missed But anyway how can we access to Made a PoC how I think it could be done: https://gist.github.com/anti-social/22830244ada08c539956921e977b252b |
Why do you need to have such an access? |
For example Rust's most popular libraries collect all options into a single struct:
I think it's much more flexible API. |
There can be global options. Also every command can have its own options. |
You can have global options in the main parser and options for each subcommand on any level. Could you provide a real usecase when option from |
As I understand it is possible only if all global options and subcommand classes are defined in the function scope. Cannot find this as a nice solution.
I don't have a real use case. This is just an example that API could be more flexible. What I really need is parsing arguments inside a suspend function. IMHO parser shouldn't execute commands. It should only parse arguments. |
Feel free to close the issue if you have different opinion. |
We're open to any ideas. Subcommands are marked as |
I'll try to collect advantages of this approach.
I know in Rust all the power of macroses are engaged for that. In Kotlin it's not an option but I still believe it could be done in a nice API. |
This could definitely make good use of kotlinx-serialization. |
I have a couple questions about the example, but in general I like the direction. I'm a bit confused in the code example by The latter is an implementation that's tied to the name of the subcommand, but that seems like adding a model inconsistency back in? How are nested subcommands defined in this model? For instance Is there a root command, or is this a homogenous tree of subcommands? Is this suggesting dropping automatic execution facilities entirely, or is this simply not shown? Are we still able to automatically generate help blurbs with this structure? |
Processing options with sub-commands looks curiously.
ArgParser.parse
method without sub-commands just parses options. But sub-commands require different code organization.I would suggest something that looks like:
Such an API will make possible definition of nested sub-commands.
The text was updated successfully, but these errors were encountered: