I am using commander@2.9.0. Attached the code below
package.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);
}
On executing in command-line,
cmdtools Hello
index.js file opens without any output in the command-line
On executing,
npm test
The output is
Input: hello
What am I missing ?