options-defaults.js
This file
Path
examples/options-defaults.js
21 lines · 429 bytes · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
12345678910111213141516171819202122#!/usr/bin/env node
// This is used as an example in the README for:// Default option value
import { Command } from 'commander';const program = new Command();
program.option( '-c, --cheese <type>', 'Add the specified type of cheese', 'blue',);
program.parse();
console.log(`cheese: ${program.opts().cheese}`);
// Try the following:// node options-defaults.js// node options-defaults.js --cheese stilton