Skip to content
Myr

defaultCommand.js

This file

Path

examples/defaultCommand.js

36 lines · 952 bytes · JavaScript

Last changed by

Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36

History of this file

Take it

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

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

lines 1–31why, one step back
1#!/usr/bin/env node
23// const commander = require('commander'); // (normal include)4const commander = require('../'); // include commander in git clone of commander repo5const program = new commander.Command();67// Example program using the command configuration option isDefault to specify the default command.89program10 .command('build')11 .description('build web site for deployment')12 .action(() => {13 console.log('build');14 });1516program17 .command('deploy')18 .description('deploy web site to production')19 .action(() => {20 console.log('deploy');21 });2223program24 .command('serve', { isDefault: true })25 .description('launch web server')26 .option('-p,--port <port_number>', 'web port')27 .action((options) => {28 console.log(`server on port ${options.port}`);29 });3031program.parse(process.argv);

Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36

lines 32–36why, one step back
32
33// Try the following:34// node defaultCommand.js build35// node defaultCommand.js serve -p 808036// node defaultCommand.js -p 443