Skip to content
Myr

Merge pull request #791 from yausername/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

updated readme with custom event listeners.

authored by Roman Vanesyan · committed by GitHub · parents dcddf69, 503845b · Browse files · 1 file+16 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+16 added−0 removed

  • other:+16 added−0 removed

1 file+16 added−0 removed

modified:Readme.md+16 added
354 unmodified lines
355356 Output help information and exit immediately.357 Optional callback cb allows post-processing of help text before it is displayed.358359360## Custom event listeners361 You can execute custom actions by listening to command and option events.362363```js364program.on('option:verbose', function () {365 process.env.VERBOSE = this.verbose;366});367368// error on unknown commands369program.on('command:*', function () {370 console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));371 process.exit(1);372});373```374375## Examples376377```js378var program = require('commander');
46 unmodified lines