cac icon indicating copy to clipboard operation
cac copied to clipboard

When we have field `choices` of `option`, we have to give flag one precise value

Open Gnosnay opened this issue 7 years ago • 2 comments

When we have field choices of option, we have to give flag one precise value.

const cac = require('../')

const cli = cac()

cli.command('a', {
  desc: 'command a',
}).option('foo', {
  desc: 'foo is a flag for command a'.
  type: "string",
  default: "aa", 
  choices: ["aa", "bb", "cc"]
})

We have to give the value to flag of foo. like that:

$ cli a
# error msg
The value of flag "foo" should be one of: "aa","bb","cc"
$ cli a --foo aa
# pass

Gnosnay avatar Sep 06 '18 08:09 Gnosnay

Oh I think it should pass when the flag value is undefined unless require: true is set, PR welcome for fixes 😅

egoist avatar Sep 06 '18 08:09 egoist