-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pattern with this in action handler, from EventEmitter (#1664)
- Loading branch information
1 parent
253f4ff
commit c6e0ee8
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env node | ||
|
||
// This example is used as an example in the README for the action handler. | ||
|
||
// const { Command } = require('commander'); // (normal include) | ||
const { Command } = require('../'); // include commander in git clone of commander repo | ||
const program = new Command(); | ||
|
||
program | ||
.command('serve') | ||
.argument('<script>') | ||
.option('-p, --port <number>', 'port number', 80) | ||
.action(function() { | ||
console.error('Run script %s on port %s', this.args[0], this.opts().port); | ||
}); | ||
|
||
program.parse(); | ||
|
||
// Try the following: | ||
// node action-this.js serve --port 8080 index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters