options-defaults.js
This file
Path
examples/options-defaults.js
19 lines · 545 bytes · JavaScript
Last changed by
Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71
History of this fileTake it
1234567891011121314151617181920#!/usr/bin/env node
// This is used as an example in the README for:// Default option value
// const commander = require('commander'); // (normal include)const commander = require('../'); // include commander in git clone of commander repoconst program = new commander.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