pizza
This file
Path
examples/pizza
27 lines · 869 bytes
Last changed by
Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36
History of this fileTake it
1#!/usr/bin/env node23// const { Command } = require('commander'); // (normal include)4const { Command } = require('../'); // include commander in git clone of commander repo5const program = new Command();67program8 .description('An application for pizza ordering')9 .option('-p, --peppers', 'Add peppers')10 .option('-c, --cheese <type>', 'Add the specified type of cheese', 'marble')11 .option('-C, --no-cheese', 'You do not want any cheese');1213program.parse();1415const options = program.opts();16console.log('you ordered a pizza with:');17if (options.peppers) console.log(' - peppers');18const cheese = !options.cheese ? 'no' : options.cheese;19console.log(' - %s cheese', cheese);2021// Try the following on macOS or Linux:22// ./pizza --help 23//24// Try the following:25// ./pizza --help 26// node pizza --peppers --cheese=blue27// node pizza --no-cheese