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
123456789101112131415161718192021222324252627282930313233343536#!/usr/bin/env node
// This example shows using addHelpText.
import { Command } from 'commander';const 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