%PDF- %PDF-
Direktori : /usr/share/doc/node-commander/examples/ |
Current File : //usr/share/doc/node-commander/examples/pizza |
#!/usr/bin/env node // const { Command } = require('commander'); // (normal include) const { Command } = require('../'); // include commander in git clone of commander repo const program = new Command(); program .description('An application for pizza ordering') .option('-p, --peppers', 'Add peppers') .option('-c, --cheese <type>', 'Add the specified type of cheese', 'marble') .option('-C, --no-cheese', 'You do not want any cheese'); program.parse(); const options = program.opts(); console.log('you ordered a pizza with:'); if (options.peppers) console.log(' - peppers'); const cheese = !options.cheese ? 'no' : options.cheese; console.log(' - %s cheese', cheese); // Try the following on macOS or Linux: // ./pizza --help // // Try the following: // ./pizza --help // node pizza --peppers --cheese=blue // node pizza --no-cheese