-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Mutually exclusive required options #1137
Comments
Hi, You could try making a subclass of option as suggested here: Also see these issues for related discussion: I am going to close this since something similar has been proposed and rejected in the past. However if you have a strong case for including something like this in click feel free to continue discussing it here. (Or if I've misunderstood what you're asking for.) |
This feature has been requested 4 years ago. It has been requested multiple times. It is listed as missing functionality on multiple blogs. Is the basis of rejections a combination of (1) having to modify interface and (2) you can implement it yourself? Or am I misunderstanding something here? |
I use this in several projects https://gist.github.com/jacobtolar/fb80d5552a9a9dfc32b12a829fa21c0c |
Based on the original rejection, it looks like Armin didn't think there was a clean way to implement this. It is also fairly easy to subclass option and get the requested behavior, which I think is a compelling reason to not add it to Click unless there is a really clean API for it. Alternatively maybe we could add a section of some more subclass examples to the docs? |
Hi.
I have a situation where there's 3 ways a subcommand can go and each has a distinct option assigned to it. One of 3 has to be picked, but never in a combination with others.
Is there a way to achieve native click
required=True
- type of functionality(prompts, errors etc) in such case? So far I'm left with forest of ugly ifs.The text was updated successfully, but these errors were encountered: