Skip to content
Myr

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 file

Take 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 back
1#!/usr/bin/env node
23// 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');14

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

line 15why, one step back
15program.parse();

Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36

lines 16–21why, one step back
16
17console.log(`Cheese type: ${program.opts().cheese}`);1819// Try the following:20// node options-required.js21// node options-required.js --cheese blue