Skip to content

Mutual exclusive subcommand and ArgGroup #1740

Answered by remkop
Onedy asked this question in Q&A
Discussion options

You must be logged in to vote

Is there a way to create a mutual exclusion between a subcommand and an ArgGroup?

No, not really. But then: do you really need to? (And for that matter, do you really need to use an ArgGroup?)

If you have a parent command with options/parameters and a subcommand, then the user may specify any combination.

stats stop
stats <tweetUrl> [-l]
stats <tweetUrl> [-l] stop

Is this really a problem?
The application could just choose to ignore input that is not applicable...

And, if it is a problem, then you can add validation logic in the stopLive() method and throw a ParameterException like described in the custom validation section of the manual.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Onedy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants