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
12345678910111213141516171819202122232425262728293031323334#!/usr/bin/env node
// This example shows using addHelpText.
// const { Command } = require('commander'); // (normal include)const { Command } = require('../'); // include commander in git clone of commander repoconst program = new Command();
program.name('awesome');
program .addHelpText('beforeAll', 'A W E S O M E\n') .addHelpText('afterAll', (context) => { if (context.error) { return '\nHelp being displayed for an error'; } return '\nSee web site for further help'; });
program .command('extra') .addHelpText('before', 'Note: the extra command does not do anything') .addHelpText('after', `Examples: awesome extra --help awesome help extra`);
program.parse();
// Try the following:// node custom-help-text.js --help// node custom-help-text.js extra --help// node custom-help-text.js