【发布时间】:2021-06-19 23:59:33
【问题描述】:
有人可以解释为什么下面的脚本没有显示所有命令的帮助吗?
test.js [command]
Commands:
test.js list-spaces List spaces
Options:
--help Show help [boolean]
--version Show version number [boolean]
请注意,list-commands 的帮助由于某种原因丢失了。
#!/usr/bin/env node
'use strict'
const yargs = require("yargs");
yargs.command({
command: 'list-spaces',
describe: 'List spaces',
type: 'boolean',
handler: function(argv) {
console.log('aaa');
}
}).argv;
yargs.command({
command: 'list-connectors',
describe: 'List connectors',
builder: {
space: {
describe: 'space',
demandOption: true,
type: 'string'
},
},
handler: function(argv) {
console.log(argv.space);
}
}).argv;
【问题讨论】:
-
你的意思是
list-connectors,而不是list-commands? -
你可以像这样链接命令:
yargs.command().command().command().help().argv
标签: javascript node.js ecmascript-6 yargs