Skip to content
Myr

options-common.js

This file

Path

examples/options-common.js

26 lines · 873 bytes · JavaScript

Last changed by

Remove incorrect example output (#1532)John Geebefore adoptiond282f20

History of this file

Take it

The walk stopped after 200 commits: lines older than 2aad525 point at it.

Update dependencies (#1214)John Geebefore adoption2aad525

lines 1–16why, one step back
1#!/usr/bin/env node
23// This is used as an example in the README for:4// Common option types, boolean and value56// const commander = require('commander'); // (normal include)7const commander = require('../'); // include commander in git clone of commander repo8const program = new commander.Command();910program11 .option('-d, --debug', 'output extra debugging')12 .option('-s, --small', 'small pizza size')13 .option('-p, --pizza-type <type>', 'flavour of pizza');1415program.parse(process.argv);16

Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71

lines 17–18why, one step back
17const options = program.opts();
18if (options.debug) console.log(options);

Update dependencies (#1214)John Geebefore adoption2aad525

line 19why, one step back
19console.log('pizza details:');

Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71

lines 20–24why, one step back
20if (options.small) console.log('- small pizza size');
21if (options.pizzaType) console.log(`- ${options.pizzaType}`);2223// Try the following:24// node options-common.js -p

Remove incorrect example output (#1532)John Geebefore adoptiond282f20

line 25why, one step back
25// node options-common.js -d -s -p vegetarian

Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71

line 26why, one step back
26// node options-common.js --pizza-type=cheese