defaultCommand.js
This file
Path
examples/defaultCommand.js
35 lines · 830 bytes · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
The walk stopped after 200 commits: lines older than 471ec40 point at it.
Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 1–2why, one step back1#!/usr/bin/env node2Switching to esm-only (#2464)John Geebefore adoptionf4bd470
lines 3–4why, one step back3import { Command } from 'commander';4const program = new Command();Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 5–35why, one step back56// 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