Skip to content
Myr

defaultCommand.js

This file

Path

examples/defaultCommand.js

35 lines · 843 bytes · JavaScript

Last changed by

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

History of this file

Take it

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

Prepare for 8.1John Geebefore adoptiona036bde

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 commander = require('commander');

Prepare for 8.1John Geebefore adoptiona036bde

lines 4–30why, one step back
4const program = new commander.Command();
56// Example program using the command configuration option isDefault to specify the default command.78program9 .command('build')10 .description('build web site for deployment')11 .action(() => {12 console.log('build');13 });1415program16 .command('deploy')17 .description('deploy web site to production')18 .action(() => {19 console.log('deploy');20 });2122program23 .command('serve', { isDefault: true })24 .description('launch web server')25 .option('-p,--port <port_number>', 'web port')26 .action((options) => {27 console.log(`server on port ${options.port}`);28 });2930program.parse(process.argv);

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

lines 31–35why, one step back
31
32// Try the following:33// node defaultCommand.js build34// node defaultCommand.js serve -p 808035// node defaultCommand.js -p 443