defaults
This file
Path
examples/defaults
23 lines · 795 bytes
Last changed by
Merge pull request #1305 from tj/release/6.xTomoaki Abebefore adoptionc5a5e7b
History of this fileTake it
The walk stopped after 200 commits: lines older than af17996 point at it.
chmod 644 travis.ymlabetomobefore adoptionaf17996
lines 1–2why, one step back1#!/usr/bin/env node2Merge pull request #1305 from tj/release/6.xTomoaki Abebefore adoptionc5a5e7b
line 3why, one step back3// This example shows adding default values for options.chmod 644 travis.ymlabetomobefore adoptionaf17996
line 4why, one step back4Merge pull request #1305 from tj/release/6.xTomoaki Abebefore adoptionc5a5e7b
lines 5–8why, one step back5// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo7const program = new Command();8chmod 644 travis.ymlabetomobefore adoptionaf17996
lines 9–16why, one step back9function list(val) {10 return val.split(',').map(Number);11}1213program14 .version('0.0.1')15 .option('-t, --template-engine [engine]', 'Add template [engine] support', 'jade')16 .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')Merge pull request #1305 from tj/release/6.xTomoaki Abebefore adoptionc5a5e7b
lines 17–19why, one step back17 .option('-l, --list [items]', 'Specify list items defaulting to 1,2,3', list, [1, 2, 3]);1819program.parse(process.argv);chmod 644 travis.ymlabetomobefore adoptionaf17996
lines 20–23why, one step back2021console.log(' - %s template engine', program.templateEngine);22console.log(' - %s cheese', program.cheese);23console.log(' - %j', program.list);