options-required.js
This file
Path
examples/options-required.js
21 lines · 695 bytes · JavaScript
Last changed by
Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36
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–14why, 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.78// const commander = require('commander'); // (normal include)9const commander = require('../'); // include commander in git clone of commander repo10const program = new commander.Command();1112program13 .requiredOption('-c, --cheese <type>', 'pizza must have cheese');14Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71
line 15why, one step back15program.parse();Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36
lines 16–21why, one step back1617console.log(`Cheese type: ${program.opts().cheese}`);1819// Try the following:20// node options-required.js21// node options-required.js --cheese blue