Skip to content
Myr

arguments-extra.js

This file

Path

examples/arguments-extra.js

23 lines · 825 bytes · JavaScript

Last changed by

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

History of this file

Take it

Choices for arguments (#1525)John Geebefore adoption708527e

lines 1–19why, one step back
1#!/usr/bin/env node
23// This is used as an example in the README for extra argument features.45// const commander = require('commander'); // (normal include)6const commander = require('../'); // include commander in git clone of commander repo7const program = new commander.Command();89program10 .addArgument(new commander.Argument('<drink-size>', 'drink cup size').choices(['small', 'medium', 'large']))11 .addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute'))12 .action((drinkSize, timeout) => {13 console.log(`Drink size: ${drinkSize}`);14 console.log(`Timeout (s): ${timeout}`);15 });1617program.parse();1819// Try the following:

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

lines 20–23why, one step back
20// node arguments-extra.js --help
21// node arguments-extra.js huge22// node arguments-extra.js small23// node arguments-extra.js medium 30