Skip to content

Using sub-command always invokes *  #809

Closed
@soichih

Description

With following program

  
program
  .command('com1', 'for test-com1.js')
  .command('com2', 'for test-com2.js')

program
  .command('*')
  .action(env=>{
      console.log("unknown command");
  })

program.parse(process.argv);

'*' will always be invoked regardless of what command user tries to execute.

hayashis@dev1:~/tmp/test $ node test.js com1
unknown command
here is test-com1.js
hayashis@dev1:~/tmp/test $ node test.js com2
unknown command
here is test-com2.js
hayashis@dev1:~/tmp/test $ node test.js bogus
unknown command

I believe "unknown command" should be displayed only when user enter non-existing command name.

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions