nodejs的命令行参数解析工具
var rawArgv = require('minimist')(process.argv.slice(2));
console.log(rawArgv);
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
x: 3,
y: 4,
n: 5,
a: true,
b: true,
c: true,
beep: 'boop' }
const args = require("minimist")(rawArgv, {
string: ["a"],
});
const args = require("minimist")(rawArgv, {
boolean: ["a"],
});
网友评论