@cac/option-choices
Limit valid values for CLI flag to a predefined set of choices, given as an array.
Install
yarn add @cac/option-choices
Usage
Your cli.js
:
const cac = require('cac')
const optionChoices = require('@cac/option-choices')
const cli = cac()
// Apply this plugin
cli.use(optionChoices())
cli.command('init', 'init command', () => console.log('init something'))
.option('fruit', {
choices: ['apple', 'banana'],
desc: 'Choose a fruit'
})
cli.parse()
Run node cli.js --fruit peach
and it will throw:
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
@cac/option-choices © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).
github.com/egoist · GitHub @EGOIST · Twitter @_egoistlily