Skip to content
Myr

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 file

Take 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 back
1#!/usr/bin/env node
23// This example shows using addHelpText.4

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

line 5why, one step back
5import { Command } from 'commander';

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 6–21why, one step back
6const 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 back
22 .addHelpText(
23 'after',24 `

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 25–26why, one step back
25Examples:
26 awesome extra --help

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 27–28why, one step back
27 awesome help extra`,
28 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 29–35why, one step back
29
30program.parse();3132// Try the following:33// node custom-help-text.js --help34// node custom-help-text.js extra --help35// node custom-help-text.js