Skip to content
Myr

options-extra.js

This file

Path

examples/options-extra.js

30 lines · 1.3 KiB · JavaScript

Last changed by

Use standard import in examples (#2168)John Geebefore adoption41b12cf

History of this file

Take it

The walk stopped after 200 commits: lines older than 0b0fbbe point at it.

Update dependencies (#1524)John Geebefore adoption0b0fbbe

lines 1–3why, one step back
1#!/usr/bin/env node
23// This is used as an example in the README for extra option features.

Add extended conflicts example (#1700)John Geebefore adoption1d27078

lines 4–5why, one step back
4// See also options-env.js for more extensive env examples,
5// and options-conflicts.js for more details about .conflicts().

Update dependencies (#1524)John Geebefore adoption0b0fbbe

line 6why, one step back
6

Use standard import in examples (#2168)John Geebefore adoption41b12cf

line 7why, one step back
7const { Command, Option } = require('commander');

Add .env method to Option for consulting environment variable for option value (#1587)John Geebefore adoption8571a75

line 8why, one step back
8const program = new Command();

Update dependencies (#1524)John Geebefore adoption0b0fbbe

lines 9–10why, one step back
9
10program

Add .env method to Option for consulting environment variable for option value (#1587)John Geebefore adoption8571a75

lines 11–13why, one step back
11 .addOption(new Option('-s, --secret').hideHelp())
12 .addOption(new Option('-t, --timeout <delay>', 'timeout in seconds').default(60, 'one minute'))13 .addOption(new Option('-d, --drink <size>', 'drink cup size').choices(['small', 'medium', 'large']))

Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c

line 14why, one step back
14 .addOption(new Option('-p, --port <number>', 'port number').env('PORT'))

feat(option): allow to set options as conflicting (#1678)Erez Rokahbefore adoptionfc4fd41

line 15why, one step back
15 .addOption(new Option('--donate [amount]', 'optional donation in dollars').preset('20').argParser(parseFloat))

Add Option.implies() (#1724)John Geebefore adoptiond660967

lines 16–17why, one step back
16 .addOption(new Option('--disable-server', 'disables the server').conflicts('port'))
17 .addOption(new Option('--free-drink', 'small drink included free ').implies({ drink: 'small' }));

Update dependencies (#1524)John Geebefore adoption0b0fbbe

lines 18–23why, one step back
18
19program.parse();2021console.log('Options: ', program.opts());2223// Try the following:

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

lines 24–25why, one step back
24// node options-extra.js --help
25// node options-extra.js --drink huge

Add Option.implies() (#1724)John Geebefore adoptiond660967

line 26why, one step back
26// node options-extra.js --free-drink

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

line 27why, one step back
27// PORT=80 node options-extra.js

Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c

lines 28–29why, one step back
28// node options-extra.js --donate
29// node options-extra.js --donate 30.50

feat(option): allow to set options as conflicting (#1678)Erez Rokahbefore adoptionfc4fd41

line 30why, one step back
30// node options-extra.js --disable-server --port 8000