Skip to content
Myr

options-required.js

This file

Path

examples/options-required.js

20 lines · 586 bytes · JavaScript

Last changed by

Use standard import in examples (#2168)John Geebefore adoption41b12cf

History of this file

Take it

The walk stopped after 200 commits: lines older than 0b0fbbe point at it.

Update dependencies (#1524)John Geebefore adoption0b0fbbe

lines 1–7why, 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.7

Use standard import in examples (#2168)John Geebefore adoption41b12cf

line 8why, one step back
8const commander = require('commander');

Update dependencies (#1524)John Geebefore adoption0b0fbbe

lines 9–14why, one step back
9const program = new commander.Command();
1011program12 .requiredOption('-c, --cheese <type>', 'pizza must have cheese');1314program.parse();

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

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