options-required.js
This file
Path
examples/options-required.js
19 lines · 583 bytes · JavaScript
Last changed by
Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
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–7why, one step back1#!/usr/bin/env node23// This is used as an example in the README for:4// Required option5// You may specify a required (mandatory) option using `.requiredOption`.6// The option must be specified on the command line, or by having a default value.7Use standard import in examples (#2168)John Geebefore adoption41b12cf
line 8why, one step back8const commander = require('commander');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 9–10why, one step back9const program = new commander.Command();10Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 11why, one step back11program.requiredOption('-c, --cheese <type>', 'pizza must have cheese');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 12–19why, one step back1213program.parse();1415console.log(`Cheese type: ${program.opts().cheese}`);1617// Try the following:18// node options-required.js19// node options-required.js --cheese blue