commander
Advanced tools
Comparing version 2.15.1 to 2.16.0
2.16.0 / 2018-06-29 | ||
================== | ||
* Remove Makefile and `test/run` (#821) | ||
* Make 'npm test' run on Windows (#820) | ||
* Add badge to display install size (#807) | ||
* chore: cache node_modules (#814) | ||
* chore: remove Node.js 4 (EOL), add Node.js 10 (#813) | ||
* fixed typo in readme (#812) | ||
* Fix types (#804) | ||
* Update eslint to resolve vulnerabilities in lodash (#799) | ||
* updated readme with custom event listeners. (#791) | ||
* fix tests (#794) | ||
2.15.0 / 2018-03-07 | ||
@@ -3,0 +17,0 @@ ================== |
@@ -46,5 +46,5 @@ /** | ||
this.flags = flags; | ||
this.required = ~flags.indexOf('<'); | ||
this.optional = ~flags.indexOf('['); | ||
this.bool = !~flags.indexOf('-no-'); | ||
this.required = flags.indexOf('<') >= 0; | ||
this.optional = flags.indexOf('[') >= 0; | ||
this.bool = flags.indexOf('-no-') === -1; | ||
flags = flags.split(/[ ,|]+/); | ||
@@ -51,0 +51,0 @@ if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift(); |
{ | ||
"name": "commander", | ||
"version": "2.15.1", | ||
"version": "2.16.0", | ||
"description": "the complete solution for node.js command-line programs", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
"lint": "eslint index.js", | ||
"test": "make test && npm run test-typings", | ||
"test": "node test/run.js && npm run test-typings", | ||
"test-typings": "node_modules/typescript/bin/tsc -p tsconfig.json" | ||
@@ -30,10 +30,10 @@ }, | ||
"devDependencies": { | ||
"@types/node": "^7.0.55", | ||
"eslint": "^3.19.0", | ||
"@types/node": "^7.0.66", | ||
"eslint": "^4.19.1", | ||
"should": "^11.2.1", | ||
"sinon": "^2.4.1", | ||
"standard": "^10.0.3", | ||
"typescript": "^2.7.2" | ||
"typescript": "^2.9.2" | ||
}, | ||
"typings": "typings/index.d.ts" | ||
} |
@@ -7,2 +7,3 @@ # Commander.js | ||
[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://npmcharts.com/compare/commander?minimal=true) | ||
[![Install Size](https://packagephobia.now.sh/badge?p=commander)](https://packagephobia.now.sh/result?p=commander) | ||
[![Join the chat at https://gitter.im/tj/commander.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
@@ -236,3 +237,3 @@ | ||
Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the option from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified. | ||
Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the subcommand from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified. | ||
@@ -361,2 +362,18 @@ If the program is designed to be installed globally, make sure the executables have proper modes, like `755`. | ||
## Custom event listeners | ||
You can execute custom actions by listening to command and option events. | ||
```js | ||
program.on('option:verbose', function () { | ||
process.env.VERBOSE = this.verbose; | ||
}); | ||
// error on unknown commands | ||
program.on('command:*', function () { | ||
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' ')); | ||
process.exit(1); | ||
}); | ||
``` | ||
## Examples | ||
@@ -363,0 +380,0 @@ |
@@ -221,5 +221,5 @@ // Type definitions for commander 2.11 | ||
* | ||
* @returns {{[key: string]: string}} | ||
* @returns {{[key: string]: any}} | ||
*/ | ||
opts(): { [key: string]: string }; | ||
opts(): { [key: string]: any }; | ||
@@ -279,3 +279,3 @@ /** | ||
*/ | ||
help(cb?: (str: string) => string): void; | ||
help(cb?: (str: string) => string): never; | ||
} | ||
@@ -282,0 +282,0 @@ |
60770
426