options-implies.js
This file
Path
examples/options-implies.js
33 lines · 903 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
line 1why, one step back1#!/usr/bin/env nodeUse standard import in examples (#2168)John Geebefore adoption41b12cf
line 2why, one step back2const { Command, Option } = require('commander');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 3–6why, one step back3const program = new Command();45program6 .addOption(new Option('--quiet').implies({ logLevel: 'off' }))Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 7–22why, one step back7 .addOption(8 new Option('--log-level <level>')9 .choices(['info', 'warning', 'error', 'off'])10 .default('info'),11 )12 .addOption(13 new Option(14 '-c, --cheese <type>',15 'Add the specified type of cheese',16 ).implies({ dairy: true }),17 )18 .addOption(19 new Option('--no-cheese', 'You do not want any cheese').implies({20 dairy: false,21 }),22 )Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 23–33why, one step back23 .addOption(new Option('--dairy', 'May contain dairy'));2425program.parse();26console.log(program.opts());2728// Try the following:29// node options-implies.js30// node options-implies.js --quiet31// node options-implies.js --log-level=warning --quiet32// node options-implies.js --cheese=cheddar33// node options-implies.js --no-cheese