-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Mark options as required together #1802
Comments
Short version: yes, craft yourself. Long version Until recently there was not really any support for options interacting. There still isn't any support for conditional option dependencies (and none planned), but there is now support for
|
Some routines and proposals in other packages. Oclif has Python
Yargs has A description of suggestion for |
This issue has not had any activity in a few months. It isn't likely to get acted on due to this report. Feel free to open a new issue if it comes up again, with new information and renewed interest. Thank you for your contributions. |
Hi, do you have an example of if this is actually possible to do ourselves? I tried this
and I want the CLI tool itself to say that one of "--case" or "--all" is required. (I was also separately assuming that if I threw a So is there a better way to actually make this work right now? |
That was a reasonable thing to try, but Commander only catches There is support for invoking the Commander error handling to display an error using
Separately, a short option is a single dash and a single letter. It is optional. So you might use |
Ah didn't realize that |
I have a use case where I could like to require my command options to be conditionally required, and exclusive. For example, let's say my
testing
command has three options:-x, --one <number>
-y, --two <number>
-z, --three <number>
I'd like to make it where the command either needs
-x
provided or both-y
and-z
together. The.conflicts()
support makes it easy to ensure that they aren't used together where they shouldn't be but there doesn't seem to be a way to mark-x
as required when-y
and/or-z
isn't used, nor is there a way to mark it such that both-y
and-z
must be used in combination together when-x
isn't used.I could craft a way to do this myself, and I've searched the project to see if this has been discussed before, but I can't find anything.
The text was updated successfully, but these errors were encountered: