-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Support required
flags
#51
Comments
In most cases I would handle this in the API. Any reason you need to do it in the CLI? |
I agree with @kevva. I believe this should be handled by the code that is called. That allows the most flexibility with informative custom error messages. |
Going to close for now. If there are some good arguments for having this as an option we might re-open it again. |
I'm gonna reopen this as I think it could be useful for CLI only tools (ones that don't have an API). It could be specified like: flags: {
rainbow: {
type: 'boolean',
alias: 'r',
required: true
}
} We should be clear in the docs that API level option validation should be preferred. The |
@issuehuntfest has funded $60.00 to this issue. See it on IssueHunt |
If a required field takes a function, should the expected return value of the function be a boolean? A quick example could be helpful as I am currently working in this. Thanks |
@HackAfro has submitted a pull request. See it on IssueHunt |
Yes
{
flags: {
rainbow: {
type: 'boolean',
required: (input, flags) => flags.unicorn === '🦄'
}
}
} Note, I'm not exactly sure what the function arguments should be. I'm open to suggestions there. I guess the I also think we should call the option |
If anyone wants to work on this, see the previous attempt here and the feedback given: #110 |
@sindresorhus has rewarded $54.00 to @sbencoding. See it on IssueHunt
|
Can we get this, but for input (non-flag arguments)? |
Some options must always be specified.
I want to have a way to specify the required options in API.
Example
A program without required options must quit with an error message.
IssueHunt Summary
sbencoding has been rewarded.
Backers (Total: $60.00)
Submitted pull Requests
Tips
The text was updated successfully, but these errors were encountered: