forked from tj/commander.js
/
env
executable file
·29 lines (23 loc) · 765 Bytes
/
env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env node
// This example shows specifying the arguments for the program to pass to the action handler.
// const { Command } = require('commander'); // (normal include)
const { Command } = require('../'); // include commander in git clone of commander repo
const program = new Command();
let cmdValue;
let envValue;
program
.version('0.0.1')
.arguments('<cmd> [env]')
.description('test command', {
cmd: 'command to run',
env: 'environment to run test in'
})
.action(function(cmdValue, envValue) {
console.log('command:', cmdValue);
console.log('environment:', envValue || 'no environment given');
});
program.parse(process.argv);
// Try the following:
// node env --help
// node env add
// node env add browser