-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathoptions-common.js
More file actions
executable file
·25 lines (19 loc) · 751 Bytes
/
Copy pathoptions-common.js
File metadata and controls
executable file
·25 lines (19 loc) · 751 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
#!/usr/bin/env node
// This is used as an example in the README for:
// Common option types, boolean and value
import { Command } from 'commander';
const program = new Command();
program
.option('-d, --debug', 'output extra debugging')
.option('-s, --small', 'small pizza size')
.option('-p, --pizza-type <type>', 'flavour of pizza');
program.parse(process.argv);
const options = program.opts();
if (options.debug) console.log(options);
console.log('pizza details:');
if (options.small) console.log('- small pizza size');
if (options.pizzaType) console.log(`- ${options.pizzaType}`);
// Try the following:
// node options-common.js -p
// node options-common.js -d -s -p vegetarian
// node options-common.js --pizza-type=cheese