OSDN Git Service

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