我试图弄清楚如何记录和别名一个不带值的参数yargs
我想要做的是别名-c
并--compile
能够记录--compile
. 如果--compile
script sources -c
我期待它是这样的
var argv = require('yargs')
.usage('Usage: $0 <input> [options]')
.example('$0 src/**.js -c', 'Generate a build')
.demand(1)
.boolean('compile')
.alias('compile', ['c'])
.nargs('c', 1)
.describe('compile', 'Whether to compile the results')
.version(function() {
return require('../package').version;
})
.argv;
但是调用script sources -c
会报错
TypeError: Cannot read property 'newAliases' of undefined
at Object.self.help (/home/gyeates/code/lodash.modularize/node_modules/yargs/lib/usage.js:135:45)
at Object.self.showHelp (/home/gyeates/code/lodash.modularize/node_modules/yargs/lib/usage.js:211:29)
at Object.Argv.self.showHelp (/home/gyeates/code/lodash.modularize/node_modules/yargs/index.js:303:15)
at Object.self.fail (/home/gyeates/code/lodash.modularize/node_modules/yargs/lib/usage.js:37:39)