-
StackOverflow 文档
-
Node.js 教程
-
解析命令行参数
-
传递动作(动词)和值
const options = require("commander");
options
.option("-v, --verbose", "Be verbose");
options
.command("convert")
.alias("c")
.description("Converts input file to output file")
.option("-i, --in-file <file_name>", "Input file")
.option("-o, --out-file <file_name>", "Output file")
.action(doConvert);
options.parse(process.argv);
if (!options.args.length) options.help();
function doConvert(options){
//do something with options.inFile and options.outFile
};