Skip to content

Commit

Permalink
Merge pull request #791 from yausername/master
Browse files Browse the repository at this point in the history
updated readme with custom event listeners.
  • Loading branch information
roman-vanesyan committed May 3, 2018
2 parents dcddf69 + 503845b commit 988d09b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Readme.md
Expand Up @@ -356,6 +356,22 @@ function make_red(txt) {
Output help information and exit immediately.
Optional callback cb allows post-processing of help text before it is displayed.


## 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

```js
Expand Down

0 comments on commit 988d09b

Please sign in to comment.