forked from tj/commander.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpizza
More file actions
executable file
·26 lines (21 loc) · 750 Bytes
/
pizza
File metadata and controls
executable file
·26 lines (21 loc) · 750 Bytes
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
#!/usr/bin/env node
const { Command } = require('commander');
const program = new Command();
program
.description('An application for pizza ordering')
.option('-p, --peppers', 'Add peppers')
.option('-c, --cheese <type>', 'Add the specified type of cheese', 'marble')
.option('-C, --no-cheese', 'You do not want any cheese');
program.parse();
const options = program.opts();
console.log('you ordered a pizza with:');
if (options.peppers) console.log(' - peppers');
const cheese = !options.cheese ? 'no' : options.cheese;
console.log(' - %s cheese', cheese);
// Try the following on macOS or Linux:
// ./pizza --help
//
// Try the following:
// ./pizza --help
// node pizza --peppers --cheese=blue
// node pizza --no-cheese