custom-help-text.js
This file
Path
examples/custom-help-text.js
35 lines · 742 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–4why, one step back1#!/usr/bin/env node23// This example shows using addHelpText.4Switching to esm-only (#2464)John Geebefore adoptionf4bd470
line 5why, one step back5import { Command } from 'commander';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 6–21why, one step back6const program = new Command();78program.name('awesome');910program11 .addHelpText('beforeAll', 'A W E S O M E\n')12 .addHelpText('afterAll', (context) => {13 if (context.error) {14 return '\nHelp being displayed for an error';15 }16 return '\nSee web site for further help';17 });1819program20 .command('extra')21 .addHelpText('before', 'Note: the extra command does not do anything')Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 22–24why, one step back22 .addHelpText(23 'after',24 `Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 25–26why, one step back25Examples:26 awesome extra --helpReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 27–28why, one step back27 awesome help extra`,28 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 29–35why, one step back2930program.parse();3132// Try the following:33// node custom-help-text.js --help34// node custom-help-text.js extra --help35// node custom-help-text.js