Skip to content
Myr

arguments-extra.js

This file

Path

examples/arguments-extra.js

30 lines · 736 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–4why, one step back
1#!/usr/bin/env node
23// This is used as an example in the README for extra argument features.4

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 7–8why, one step back
7
8program

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 9why, one step back
9 .addArgument(

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

line 10why, one step back
10 new Argument('<drink-size>', 'drink cup size').choices([

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 11–16why, one step back
11 'small',
12 'medium',13 'large',14 ]),15 )16 .addArgument(

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

line 17why, one step back
17 new Argument('[timeout]', 'timeout in seconds').default(60, 'one minute'),

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 18why, one step back
18 )

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 19–30why, one step back
19 .action((drinkSize, timeout) => {
20 console.log(`Drink size: ${drinkSize}`);21 console.log(`Timeout (s): ${timeout}`);22 });2324program.parse();2526// Try the following:27// node arguments-extra.js --help28// node arguments-extra.js huge29// node arguments-extra.js small30// node arguments-extra.js medium 30