thank.js
This file
Path
examples/thank.js
25 lines · 720 bytes · JavaScript
Last changed by
Use standard import in examples (#2168)John Geebefore adoption41b12cf
History of this fileTake 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–4why, one step back1#!/usr/bin/env node23// This example is used as an example in the README for the action handler.4Use standard import in examples (#2168)John Geebefore adoption41b12cf
line 5why, one step back5const { Command } = require('commander');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 6–25why, one step back6const program = new Command();78program9 .argument('<name>')10 .option('-t, --title <honorific>', 'title to use before name')11 .option('-d, --debug', 'display some debugging')12 .action((name, options, command) => {13 if (options.debug) {14 console.error('Called %s with options %o', command.name(), options);15 }16 const title = options.title ? `${options.title} ` : '';17 console.log(`Thank-you ${title}${name}`);18 });1920program.parse();2122// Try the following:23// node thank.js John24// node thank.js Doe --title Mr25// node thank.js --debug Doe --title Mr