Skip to content
Myr

pizza

This file

Path

examples/pizza

26 lines · 748 bytes

Last changed by

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

History of this file

Take it

1#!/usr/bin/env node23import { Command } from 'commander';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:21//    ./pizza --help22//23// Try the following:24//    node pizza --help25//    node pizza --peppers --cheese=blue26//    node pizza --no-cheese