Skip to content
Myr

pizza

This file

Path

examples/pizza

26 lines · 750 bytes

Last changed by

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

History of this file

Take it

The walk stopped after 200 commits: lines older than cc2db5b point at it.

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 1–2why, one step back
1#!/usr/bin/env node
2

Use standard import in examples (#2168)John Geebefore adoption41b12cf

line 3why, one step back
3const { Command } = require('commander');

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 4–20why, one step back
4const program = new Command();
56program7 .description('An application for pizza ordering')8 .option('-p, --peppers', 'Add peppers')9 .option('-c, --cheese <type>', 'Add the specified type of cheese', 'marble')10 .option('-C, --no-cheese', 'You do not want any cheese');1112program.parse();1314const options = program.opts();15console.log('you ordered a pizza with:');16if (options.peppers) console.log(' - peppers');17const cheese = !options.cheese ? 'no' : options.cheese;18console.log(' - %s cheese', cheese);1920// Try the following on macOS or Linux:

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 21why, one step back
21// ./pizza --help

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 22–23why, one step back
22//
23// Try the following:

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 24why, one step back
24// ./pizza --help

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 25–26why, one step back
25// node pizza --peppers --cheese=blue
26// node pizza --no-cheese