我正在NodeJS中使用
yargs
.usage()
yargs.usage("\nUsage: node $0 --input=path/to/input/file --output=path/to/output/file")
node cli.js --help
,如预期显示以下内容:
Usage: node cli.js --input=path/to/input/file --output=path/to/output/file
显然yargs正在扩大
$0
占位符到占位符
cli.js
,太棒了。这就是我手动包含的原因
node
在
打电话。
npm install -g
,恐怕使用情况显示
Usage: node my-utility --input=path/to/input/file --output=path/to/output/file
当然我也希望如此
Usage: my-utility --input=path/to/input/file --output=path/to/output/file
我怎样才能使这个条件检查使我只打印
节点
当它真的以这种方式被调用(而不是直接被调用)的用法中?