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
requiredOption with choices #1779
Comments
Use Background: the reason for the name change is that "required" inside the Option class has always meant the option has a required option-argument, as opposed to an optional option-argument, or no option-argument for a boolean option. When we added |
Note: the runtime test for a required option is that it has a value after parsing. When you make your option required (mandatory) you probably want to drop the default value to make the user specify a value. |
@shadowspawn Thanks for the quick reply and the remarks. I have checked the code source, but completely missed that method as I kept searching for the word "required" and only found, as you said, required argument. Will keep this issue opened as it is needed to be documented. |
Added to README in #1797 |
Added mention to README in Commander v9.4.1 |
I already had
I want to make this option required. There is
.requiredOption
but not as powerful as.addOption
(i.e. cannot specifychoices
). AFAIK there is no way to specify an optionchoices
and make it required at the same time.An
.addRequiredOption
would seem redundant. Would it be possible to add a.required()
method toOption
?The text was updated successfully, but these errors were encountered: