@cac/option-choices
Mark an option as required for specific command.
Last updated 3 years ago by rem .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @cac/option-choices 
SYNC missed versions from official npm registry.

@cac/option-choices

NPM version NPM downloads CircleCI donate chat

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:

preview

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. 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

Current Tags

  • 2.0.1                                ...           latest (3 years ago)

2 Versions

  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |