custom-help-text.js
This file
Path
examples/custom-help-text.js
33 lines · 845 bytes · JavaScript
Last changed by
Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36
History of this fileTake it
Expand help customisation with .addHelpText (#1296)John Geebefore adoptiond26a26d
lines 1–30why, one step back1#!/usr/bin/env node23// This example shows using addHelpText.45// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo7const program = new Command();89program.name('awesome');1011program12 .addHelpText('beforeAll', 'A W E S O M E\n')13 .addHelpText('afterAll', (context) => {14 if (context.error) {15 return '\nHelp being displayed for an error';16 }17 return '\nSee web site for further help';18 });1920program21 .command('extra')22 .addHelpText('before', 'Note: the extra command does not do anything')23 .addHelpText('after', `24Examples:25 awesome extra --help26 awesome help extra`);2728program.parse();2930// Try the following:Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36
lines 31–33why, one step back31// node custom-help-text.js --help32// node custom-help-text.js extra --help33// node custom-help-text.js