commander
Advanced tools
Comparing version 2.17.1 to 2.18.0
2.18.0 / 2018-09-07 | ||
================== | ||
* Standardize help output (#853) | ||
* chmod 644 travis.yml (#851) | ||
* add support for execute typescript subcommand via ts-node (#849) | ||
2.17.1 / 2018-08-07 | ||
@@ -3,0 +10,0 @@ ================== |
29
index.js
@@ -526,3 +526,3 @@ /** | ||
// name of the subcommand, link `pm-install` | ||
var bin = basename(f, '.js') + '-' + args[0]; | ||
var bin = basename(f, path.extname(f)) + '-' + args[0]; | ||
@@ -543,3 +543,3 @@ // In case of globally installed, get the base dir where executable | ||
// whether bin file is a js script with explicit `.js` extension | ||
// whether bin file is a js script with explicit `.js` or `.ts` extension | ||
var isExplicitJS = false; | ||
@@ -549,2 +549,5 @@ if (exists(localBin + '.js')) { | ||
isExplicitJS = true; | ||
} else if (exists(localBin + '.ts')) { | ||
bin = localBin + '.ts'; | ||
isExplicitJS = true; | ||
} else if (exists(localBin)) { | ||
@@ -583,5 +586,5 @@ bin = localBin; | ||
if (err.code === 'ENOENT') { | ||
console.error('\n %s(1) does not exist, try --help\n', bin); | ||
console.error('%s(1) does not exist, try --help', bin); | ||
} else if (err.code === 'EACCES') { | ||
console.error('\n %s(1) not executable. try chmod or run with root\n', bin); | ||
console.error('%s(1) not executable. try chmod or run with root', bin); | ||
} | ||
@@ -1076,3 +1079,3 @@ process.exit(1); | ||
return [ | ||
' Commands:', | ||
'Commands:', | ||
'', | ||
@@ -1082,3 +1085,3 @@ commands.map(function(cmd) { | ||
return (desc ? pad(cmd[0], width) : cmd[0]) + desc; | ||
}).join('\n').replace(/^/gm, ' '), | ||
}).join('\n').replace(/^/gm, ' '), | ||
'' | ||
@@ -1099,3 +1102,3 @@ ].join('\n'); | ||
desc = [ | ||
' ' + this._description, | ||
this._description, | ||
'' | ||
@@ -1107,6 +1110,6 @@ ]; | ||
var width = this.padWidth(); | ||
desc.push(' Arguments:'); | ||
desc.push('Arguments:'); | ||
desc.push(''); | ||
this._args.forEach(function(arg) { | ||
desc.push(' ' + pad(arg.name, width) + ' ' + argsDescription[arg.name]); | ||
desc.push(' ' + pad(arg.name, width) + ' ' + argsDescription[arg.name]); | ||
}); | ||
@@ -1122,4 +1125,3 @@ desc.push(''); | ||
var usage = [ | ||
'', | ||
' Usage: ' + cmdName + ' ' + this.usage(), | ||
'Usage: ' + cmdName + ' ' + this.usage(), | ||
'' | ||
@@ -1133,5 +1135,5 @@ ]; | ||
var options = [ | ||
' Options:', | ||
'Options:', | ||
'', | ||
'' + this.optionHelp().replace(/^/gm, ' '), | ||
'' + this.optionHelp().replace(/^/gm, ' '), | ||
'' | ||
@@ -1144,3 +1146,2 @@ ]; | ||
.concat(cmds) | ||
.concat(['']) | ||
.join('\n'); | ||
@@ -1147,0 +1148,0 @@ }; |
{ | ||
"name": "commander", | ||
"version": "2.17.1", | ||
"version": "2.18.0", | ||
"description": "the complete solution for node.js command-line programs", | ||
@@ -29,7 +29,8 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/node": "^10.5.7", | ||
"eslint": "^5.3.0", | ||
"@types/node": "^10.9.4", | ||
"eslint": "^5.5.0", | ||
"should": "^13.2.3", | ||
"sinon": "^6.1.4", | ||
"standard": "^11.0.1", | ||
"sinon": "^6.2.0", | ||
"standard": "^12.0.1", | ||
"ts-node": "^7.0.1", | ||
"typescript": "^2.9.2" | ||
@@ -36,0 +37,0 @@ }, |
@@ -48,3 +48,3 @@ # Commander.js | ||
Note that multi-word options starting with `--no` prefix negate the boolean value of the following word. For example, `--no-sauce` sets the value of `program.sauce` to false. | ||
Note that multi-word options starting with `--no` prefix negate the boolean value of the following word. For example, `--no-sauce` sets the value of `program.sauce` to false. | ||
@@ -157,3 +157,3 @@ ```js | ||
.parse(process.argv); | ||
console.log(' size: %j', program.size); | ||
@@ -253,18 +253,16 @@ console.log(' drink: %j', program.drink); | ||
``` | ||
$ ./examples/pizza --help | ||
$ ./examples/pizza --help | ||
Usage: pizza [options] | ||
Usage: pizza [options] | ||
An application for pizzas ordering | ||
An application for pizzas ordering | ||
Options: | ||
Options: | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-p, --peppers Add peppers | ||
-P, --pineapple Add pineapple | ||
-b, --bbq Add bbq sauce | ||
-c, --cheese <type> Add the specified type of cheese [marble] | ||
-C, --no-cheese You do not want any cheese | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-p, --peppers Add peppers | ||
-P, --pineapple Add pineapple | ||
-b, --bbq Add bbq sauce | ||
-c, --cheese <type> Add the specified type of cheese [marble] | ||
-C, --no-cheese You do not want any cheese | ||
``` | ||
@@ -277,3 +275,3 @@ | ||
exit once you are done so that the remainder of your program | ||
does not execute causing undesired behaviours, for example | ||
does not execute causing undesired behaviors, for example | ||
in the following executable "stuff" will not output when | ||
@@ -301,7 +299,7 @@ `--help` is used. | ||
program.on('--help', function(){ | ||
console.log(' Examples:'); | ||
console.log('') | ||
console.log('Examples:'); | ||
console.log(''); | ||
console.log(' $ custom-help --help'); | ||
console.log(' $ custom-help -h'); | ||
console.log(''); | ||
console.log(' $ custom-help --help'); | ||
console.log(' $ custom-help -h'); | ||
}); | ||
@@ -317,3 +315,2 @@ | ||
``` | ||
Usage: custom-help [options] | ||
@@ -333,3 +330,2 @@ | ||
$ custom-help -h | ||
``` | ||
@@ -412,7 +408,7 @@ | ||
}).on('--help', function() { | ||
console.log(' Examples:'); | ||
console.log(); | ||
console.log(' $ deploy exec sequential'); | ||
console.log(' $ deploy exec async'); | ||
console.log(); | ||
console.log(''); | ||
console.log('Examples:'); | ||
console.log(''); | ||
console.log(' $ deploy exec sequential'); | ||
console.log(' $ deploy exec async'); | ||
}); | ||
@@ -419,0 +415,0 @@ |
61367
1348
7
422