cacjs/cac

could I use default command(not the global one with name '@@global@@')?

richardo2016 opened this issue · 1 comments

Issue Type

  • Bug Report
  • Feature Request
  • Other

run code below:

cli.command('[...rest]', 'desc')
    .option('--out', 'desc')
    .action(...)

const parsed = cli.parse(['', '', './src', '--out', './lib'], { run: false});

console.log(parsed)

Expected

{
  "args": [
    "./src",
    "abc"
  ],
  "options": {
    "--": [],
    "out": "./lib"
  }
}

Actual

{
  "args": [
    "./src"
  ],
  "options": {
    "--": [],
    "out": true
  }
}

Possible Solutions

Info

  • CAC version: 6.7.x
  • Reproduction link:

finally I found I should customize option like this:

cli.command('[...rest]', 'desc')
    .option('--out [out]', 'desc') // add one option var name with bracket here 🤔
    .action(...)

const parsed = cli.parse(['', '', './src', '--out', './lib'], { run: false});

console.log(parsed)

then cli.parse works as I expected.