options-implies.js
This file
Path
examples/options-implies.js
33 lines · 898 bytes · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
The walk stopped after 200 commits: lines older than 471ec40 point at it.
Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 1why, one step back1#!/usr/bin/env nodeSwitching to esm-only (#2464)John Geebefore adoptionf4bd470
line 2why, one step back2import { Command, Option } from 'commander';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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