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 fileTake 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 back1#!/usr/bin/env node23// 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);16Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71
lines 17–18why, one step back17const options = program.opts();18if (options.debug) console.log(options);Update dependencies (#1214)John Geebefore adoption2aad525
line 19why, one step back19console.log('pizza details:');Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71
lines 20–24why, one step back20if (options.small) console.log('- small pizza size');21if (options.pizzaType) console.log(`- ${options.pizzaType}`);2223// Try the following:24// node options-common.js -pRemove incorrect example output (#1532)John Geebefore adoptiond282f20
line 25why, one step back25// node options-common.js -d -s -p vegetarianChange to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71
line 26why, one step back26// node options-common.js --pizza-type=cheese