#1680·yargs

全球后记

作者: astorije创建于 2020年6月26日更新于 2026年8月2日
标签triagedfeature request

考虑以下(非常)简化的示例:

typescript
yargs
  .scriptName('foo')
  .options({ baz: {} })
  .command('bar', 'The bar command')
  .epilogue('Epilogue goes here').argv;

foo --help 会显示结尾信息:

foo [command]

Commands:
  foo bar  The bar command
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --baz
Epilogue goes here

foo bar --help 则不会显示结尾信息:

foo bar
The bar command
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --baz

从这个意义上讲,在顶层定义 epilogue 与在顶层定义 options 有不同的作用。