options-common.js
This file
Path
examples/options-common.js
25 lines · 764 bytes · JavaScript
Last changed by
Use standard import in examples (#2168)John Geebefore adoption41b12cf
History of this fileTake it
The walk stopped after 200 commits: lines older than 3103c6b point at it.
Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 1–5why, one step back1#!/usr/bin/env node23// This is used as an example in the README for:4// Common option types, boolean and value5Use standard import in examples (#2168)John Geebefore adoption41b12cf
line 6why, one step back6const commander = require('commander');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 7–25why, one step back7const program = new commander.Command();89program10 .option('-d, --debug', 'output extra debugging')11 .option('-s, --small', 'small pizza size')12 .option('-p, --pizza-type <type>', 'flavour of pizza');1314program.parse(process.argv);1516const options = program.opts();17if (options.debug) console.log(options);18console.log('pizza details:');19if (options.small) console.log('- small pizza size');20if (options.pizzaType) console.log(`- ${options.pizzaType}`);2122// Try the following:23// node options-common.js -p24// node options-common.js -d -s -p vegetarian25// node options-common.js --pizza-type=cheese