OSDN Git Service

Regular updates
[twpd/master.git] / commander.js.md
1 ---
2 title: Commander.js
3 category: JavaScript libraries
4 ---
5
6 ### Initialize
7
8     var cli = require('commander');
9
10 ### Options
11
12     cli
13       .version(require('../package').version)
14       .usage('[options] <command>')
15       .option('-w, --words <n>', 'generate <n> words')
16       .option('-i, --interval <n>', 'interval [1000]', 1000)
17       .option('-s, --symbols', 'include symbols')
18       .parse(process.argv);
19
20 ### Help
21
22     .on('--help', function() {
23       console.log('');
24     })
25
26 ### Commands
27
28     cli.outputHelp();
29     cli.args == ["hello"];
30
31 ### Other useful things
32
33     process.exit(0);
34
35