Support mutually exclusive options#147
Conversation
|
I've been thinking about this for past few days and unfortunately I think this is not a right API for the solution. There are few issues, but I think the main is that is does not allow to cover this case from the linked issue:
It's not very easy for me to come up with a sensible alternative, but after trying some option I think this could work better here: option :ff_only, type: :boolean, excludes: [:no_ff, :rebase]
option :no_ff, type: :boolean, excludes: :ff_only
option :rebase, type: :boolean, excludes: :ff_onlyIt is quite verbose, I know. But it's explicit and verbosity might encourage users to reevaluate if the validation should lie within CLI handling, or rather inside the application code. The main downside is that it's easy to forget to forbid combining option in one direction (like: I would also allow adding Possible alternativeThere is kind of options that is strictly mutually exclusive almost on a syntactic level. Think option :with_ssl`, type: :boolean, inverted_as: :without_sslThis would only be allowed for boolean options and specifying what Any thoughts @timriley @aaronmallen? |
Resolve #128
This PR adds support to mutually exclusive options (i.e. options that cannot be used together). The implemented API is exemplified bellow. I'm not totally satisfied with the current API, so any suggestions will be appreciated.