我正在使用command@2.9.0。附上下面的代码
包.json
{
"name": "commandtools",
"version": "1.0.0",
"description": "A command line example",
"main": "index.js",
"scripts": {
"test": "node index.js hello"
},
"author": "aaa <aaa@xxx.com>",
"license": "MIT",
"bin": {
"cmdtools":"./index.js"
},
"dependencies": {
"commander": "^2.9.0"
}
}
index.js
var program = require('commander');
program
.version('0.0.1')
.usage('<input>')
.parse(process.argv);
if(!program.args.length) {
program.help();
} else {
console.log('Input: ' + program.args);
}
在命令行中执行时,
cmdtools Hello
index.js 文件在命令行中打开而没有任何输出
执行时,
npm test
输出是
Input: hello
我错过了什么?