arguments-extra.js
This file
Path
examples/arguments-extra.js
33 lines · 778 bytes · JavaScript
Last changed by
Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
History of this fileTake it
The walk stopped after 200 commits: lines older than 3103c6b point at it.
Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 1–4why, one step back1#!/usr/bin/env node23// This is used as an example in the README for extra argument features.4Use standard import in examples (#2168)John Geebefore adoption41b12cf
line 5why, one step back5const commander = require('commander');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 6–8why, one step back6const program = new commander.Command();78programReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 9–21why, one step back9 .addArgument(10 new commander.Argument('<drink-size>', 'drink cup size').choices([11 'small',12 'medium',13 'large',14 ]),15 )16 .addArgument(17 new commander.Argument('[timeout]', 'timeout in seconds').default(18 60,19 'one minute',20 ),21 )Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 22–33why, one step back22 .action((drinkSize, timeout) => {23 console.log(`Drink size: ${drinkSize}`);24 console.log(`Timeout (s): ${timeout}`);25 });2627program.parse();2829// Try the following:30// node arguments-extra.js --help31// node arguments-extra.js huge32// node arguments-extra.js small33// node arguments-extra.js medium 30