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 3103c6b point at it.

Add more tests for implies (#1730)John Geebefore adoption3103c6b

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');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 4–35why, 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);3132// Try the following:33// node defaultCommand.js build34// node defaultCommand.js serve -p 808035// node defaultCommand.js -p 443