-
Notifications
You must be signed in to change notification settings - Fork 293
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
Possibility to make an "option group" where the user has to use exactly one of the options in the group #66
Comments
Again @pheiberg thanks for posting the issue. Issue contributes to make the library better (implying that issue will be fixed...) and so are always welcome. This is issue was filed under enhancement, because this is a known behavior; also if not enough to describe your syntax. Thanks for the reference, I'll read it. It' always good know what other do... At glance A bit more in depth This is one of the key reason that have me brought to heavily refactoring the kernel and try to adhere some functional principles; but the second point is in its earliest stages. :)) Going ahead, I'm agree that such behaviour should be semantically supported by the parser (no exception -> we will be implemented). Conclusion C/C: @nemec @mizipzor (main contrib. opinion appreciated) |
I want to add one thing, since its an enhancement, fixing will be delayed until some refactorings occur in persing kernel. Anyway we're a talking of very limited amount of time. As you can see all enhancement are freezed during this time. Metrics: we're taliking of days not months!!! |
Work is not stopped, please read https://github.com/gsscoder/commandline/wiki/Official-Roadmap |
@pheiberg Check PRs this should be solved as now. If you're satisfied, please let me if I can close this issue. Thanks. |
Considering the lack of activity, it's time to close this (just reopen if need be). |
When creating an application that has a group of options of which one must be given and only one of them can be given at a time, there is currently no way to do that.
MutuallyExclusiveSet
andRequired
can't be used together.Example: I have an application where the user either can process files using
MyApp --files myfile.txt
or get a list of possible languages to use to process the files
MyApp --list-languages
or get a list of available plugins
MyApp --list-plugins
etc
Using more than one option or none of them would render an error.
A verb based approach could solve it, but seems wrong since the applications only real command is to process files and the rest of the command would just be some sort of help commands.
The Plossum Command Line Parser is using the notion of OptionGroups, where a group can have a setting of:
This would be a good way to solve it IMO.
Another alternative I can think of - off the top of my head - would be to allow
MutuallyExclusiveSet
andRequired
to be combined. An option withRequired
would then cause it'sMutuallyExclusiveSet
to be required instead of the option.A stackoverflow question on this issue is posted here.
The text was updated successfully, but these errors were encountered: