arguments-extra.js
This file
Path
examples/arguments-extra.js
22 lines · 716 bytes · JavaScript
Last changed by
Use standard import in examples (#2168)John Geebefore adoption41b12cf
History of this fileTake it
Choices for arguments (#1525)John Geebefore adoption708527e
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');Choices for arguments (#1525)John Geebefore adoption708527e
lines 6–18why, one step back6const program = new commander.Command();78program9 .addArgument(new commander.Argument('<drink-size>', 'drink cup size').choices(['small', 'medium', 'large']))10 .addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute'))11 .action((drinkSize, timeout) => {12 console.log(`Drink size: ${drinkSize}`);13 console.log(`Timeout (s): ${timeout}`);14 });1516program.parse();1718// Try the following:Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36
lines 19–22why, one step back19// node arguments-extra.js --help20// node arguments-extra.js huge21// node arguments-extra.js small22// node arguments-extra.js medium 30