Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Created November 12, 2015 01:05
Show Gist options
  • Save Teino1978-Corp/b3dfd444833e89ae1ed5 to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/b3dfd444833e89ae1ed5 to your computer and use it in GitHub Desktop.
commander.js command with actions
var program = require('commander');
program
.command('create [name]')
.description('create environment')
.action(function() {
console.log(1);
});
program
.command('use [name]')
.description('use environment')
.action(function() {
console.log(2);
});
program.parse(process.argv);
//
// $ node cli.js create test
// 1
// $ node cli.js use test
// 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment