Skip to content
Myr

options-required.js

This file

Path

examples/options-required.js

19 lines · 570 bytes · JavaScript

Last changed by

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

History of this file

Take it

The walk stopped after 200 commits: lines older than 471ec40 point at it.

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

lines 8–9why, one step back
8import { Command } from 'commander';
9const program = new Command();

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 10why, one step back
10

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 11why, one step back
11program.requiredOption('-c, --cheese <type>', 'pizza must have cheese');

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 12–19why, one step back
12
13program.parse();1415console.log(`Cheese type: ${program.opts().cheese}`);1617// Try the following:18// node options-required.js19// node options-required.js --cheese blue