Created
November 22, 2016 22:38
-
-
Save peterhughesdev/93c6a4cd6221746021dc0e86e30fad78 to your computer and use it in GitHub Desktop.
Basic usage of commander.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
var commander = require('commander'); | |
commander.version('0.0.1') | |
.option('-h, --host <n>', 'The hostname', 'localhost') | |
.option('-p, --port <n>', 'The port', 8080) | |
.option('-t, --topic <n>', 'The topic', 'foo') | |
.parse(process.argv); | |
var host = commander.host | |
var port = commander.port | |
var topic = commander.topic | |
console.log(host, port, topic); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
node index.js -h some.host.com --port 8081
Should output:
some.host.com 8081 foo