commander 2.15.1 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/Readme.md +18 -1
- package/index.js +3 -3
- package/package.json +5 -5
- package/typings/index.d.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
2.16.0 / 2018-06-29
|
|
3
|
+
==================
|
|
4
|
+
|
|
5
|
+
* Remove Makefile and `test/run` (#821)
|
|
6
|
+
* Make 'npm test' run on Windows (#820)
|
|
7
|
+
* Add badge to display install size (#807)
|
|
8
|
+
* chore: cache node_modules (#814)
|
|
9
|
+
* chore: remove Node.js 4 (EOL), add Node.js 10 (#813)
|
|
10
|
+
* fixed typo in readme (#812)
|
|
11
|
+
* Fix types (#804)
|
|
12
|
+
* Update eslint to resolve vulnerabilities in lodash (#799)
|
|
13
|
+
* updated readme with custom event listeners. (#791)
|
|
14
|
+
* fix tests (#794)
|
|
15
|
+
|
|
2
16
|
2.15.0 / 2018-03-07
|
|
3
17
|
==================
|
|
4
18
|
|
package/Readme.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
[](http://travis-ci.org/tj/commander.js)
|
|
5
5
|
[](https://www.npmjs.org/package/commander)
|
|
6
6
|
[](https://npmcharts.com/compare/commander?minimal=true)
|
|
7
|
+
[](https://packagephobia.now.sh/result?p=commander)
|
|
7
8
|
[](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
8
9
|
|
|
9
10
|
The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/commander-rb/commander).
|
|
@@ -232,7 +233,7 @@ program
|
|
|
232
233
|
When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
|
|
233
234
|
The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.
|
|
234
235
|
|
|
235
|
-
Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the
|
|
236
|
+
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.
|
|
236
237
|
|
|
237
238
|
If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
|
|
238
239
|
|
|
@@ -356,6 +357,22 @@ function make_red(txt) {
|
|
|
356
357
|
Output help information and exit immediately.
|
|
357
358
|
Optional callback cb allows post-processing of help text before it is displayed.
|
|
358
359
|
|
|
360
|
+
|
|
361
|
+
## Custom event listeners
|
|
362
|
+
You can execute custom actions by listening to command and option events.
|
|
363
|
+
|
|
364
|
+
```js
|
|
365
|
+
program.on('option:verbose', function () {
|
|
366
|
+
process.env.VERBOSE = this.verbose;
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// error on unknown commands
|
|
370
|
+
program.on('command:*', function () {
|
|
371
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
|
|
372
|
+
process.exit(1);
|
|
373
|
+
});
|
|
374
|
+
```
|
|
375
|
+
|
|
359
376
|
## Examples
|
|
360
377
|
|
|
361
378
|
```js
|
package/index.js
CHANGED
|
@@ -43,9 +43,9 @@ exports.Option = Option;
|
|
|
43
43
|
|
|
44
44
|
function Option(flags, description) {
|
|
45
45
|
this.flags = flags;
|
|
46
|
-
this.required =
|
|
47
|
-
this.optional =
|
|
48
|
-
this.bool =
|
|
46
|
+
this.required = flags.indexOf('<') >= 0;
|
|
47
|
+
this.optional = flags.indexOf('[') >= 0;
|
|
48
|
+
this.bool = flags.indexOf('-no-') === -1;
|
|
49
49
|
flags = flags.split(/[ ,|]+/);
|
|
50
50
|
if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
|
|
51
51
|
this.long = flags.shift();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commander",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "the complete solution for node.js command-line programs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"commander",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"lint": "eslint index.js",
|
|
19
|
-
"test": "
|
|
19
|
+
"test": "node test/run.js && npm run test-typings",
|
|
20
20
|
"test-typings": "node_modules/typescript/bin/tsc -p tsconfig.json"
|
|
21
21
|
},
|
|
22
22
|
"main": "index",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^7.0.
|
|
30
|
-
"eslint": "^
|
|
29
|
+
"@types/node": "^7.0.66",
|
|
30
|
+
"eslint": "^4.19.1",
|
|
31
31
|
"should": "^11.2.1",
|
|
32
32
|
"sinon": "^2.4.1",
|
|
33
33
|
"standard": "^10.0.3",
|
|
34
|
-
"typescript": "^2.
|
|
34
|
+
"typescript": "^2.9.2"
|
|
35
35
|
},
|
|
36
36
|
"typings": "typings/index.d.ts"
|
|
37
37
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -218,9 +218,9 @@ declare namespace local {
|
|
|
218
218
|
/**
|
|
219
219
|
* Return an object containing options as key-value pairs
|
|
220
220
|
*
|
|
221
|
-
* @returns {{[key: string]:
|
|
221
|
+
* @returns {{[key: string]: any}}
|
|
222
222
|
*/
|
|
223
|
-
opts(): { [key: string]:
|
|
223
|
+
opts(): { [key: string]: any };
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* Set the description to `str`.
|
|
@@ -275,7 +275,7 @@ declare namespace local {
|
|
|
275
275
|
*
|
|
276
276
|
* @param {(str: string) => string} [cb]
|
|
277
277
|
*/
|
|
278
|
-
help(cb?: (str: string) => string):
|
|
278
|
+
help(cb?: (str: string) => string): never;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
}
|