Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated readme with custom event listeners. #791

Merged
merged 1 commit into from May 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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