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 fileTake 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 back1#!/usr/bin/env node23// 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 back4// 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 back6Use standard import in examples (#2168)John Geebefore adoption41b12cf
line 7why, one step back7const { Command, Option } = require('commander');Add .env method to Option for consulting environment variable for option value (#1587)John Geebefore adoption8571a75
line 8why, one step back8const program = new Command();Update dependencies (#1524)John Geebefore adoption0b0fbbe
lines 9–10why, one step back910programAdd .env method to Option for consulting environment variable for option value (#1587)John Geebefore adoption8571a75
lines 11–13why, one step back11 .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 back14 .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 back15 .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 back16 .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 back1819program.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 back24// node options-extra.js --help25// node options-extra.js --drink hugeAdd Option.implies() (#1724)John Geebefore adoptiond660967
line 26why, one step back26// node options-extra.js --free-drinkMake examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36
line 27why, one step back27// PORT=80 node options-extra.jsMerge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c
lines 28–29why, one step back28// node options-extra.js --donate29// node options-extra.js --donate 30.50feat(option): allow to set options as conflicting (#1678)Erez Rokahbefore adoptionfc4fd41
line 30why, one step back30// node options-extra.js --disable-server --port 8000