0

我有 2 个命令的 yargs?

yargs
.command('test-all','',handler)
.command('test-file','',handler)
.argv

用户输入:

node myapp.js other-command

yargs不要抛出错误。我应该怎么办?

4

1 回答 1

0

您可以使用它.demandCommand()来执行此操作:

yargs
  .command('test-all','',handler)
  .command('test-file','',handler)
  .demandCommand(1, 'You need at least one command before moving on')
  .argv
于 2020-09-02T05:29:01.513 回答