Optional choices for array
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 519
- Forks
- 129
- Avg merge
- 1h 34m
- Merged PRs (30d)
- 1
Description
I have a config like this:
filetype: {
choices: ['.js', '.jsx'],
type: 'array'
},
recursive: {
type: 'boolean'
},
So this works:
create-index --filetype .js .jsx --recursive ./src
But this throws an error:
create-index --filetype .js .jsx ./src
Invalid values:
Argument: filetype, Given: "./src", Choices: ".js", ".jsx"
There should be an option to make the choices be "optional" rather than throw an error. If it doesn't find a match it should consider the rest of the arguments to be positional arguments. This can be especially useful for arrays as shown in above example. It should throw (in case of an array) only if the first argument doesn't match.
This could possibly address yargs/yargs-parser#219
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two create-index command examples and compare how array choices handle the following positional argument. Review the related yargs/yargs-parser#219 discussion and the parser's existing choice and positional-argument tests; done means an optional choice can leave unmatched trailing arguments positional while still rejecting an unmatched first array value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100