Skip to content

Commit 2935568

Browse files
authored
TypeScript for addHelpCommand (#1375)
1 parent f15900d commit 2935568

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

typings/commander-tests.ts

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ const addCommandThis: commander.Command = program.addCommand(new commander.Comma
5555
// arguments
5656
const argumentsThis: commander.Command = program.arguments('<cmd> [env]');
5757

58+
// addHelpCommand
59+
const addHelpCommandThis1: commander.Command = program.addHelpCommand();
60+
const addHelpCommandThis3: commander.Command = program.addHelpCommand(false);
61+
const addHelpCommandThis2: commander.Command = program.addHelpCommand(true);
62+
const addHelpCommandThis4: commander.Command = program.addHelpCommand('compress <file>');
63+
const addHelpCommandThis5: commander.Command = program.addHelpCommand('compress <file>', 'compress target file');
64+
5865
// exitOverride
5966
const exitThis1: commander.Command = program.exitOverride();
6067
const exitThis2: commander.Command = program.exitOverride((err): never => {

typings/index.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ declare namespace commander {
109109
*/
110110
arguments(desc: string): this;
111111

112+
/**
113+
* Override default decision whether to add implicit help command.
114+
*
115+
* addHelpCommand() // force on
116+
* addHelpCommand(false); // force off
117+
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
118+
*
119+
* @returns `this` command for chaining
120+
*/
121+
addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this;
122+
112123
/**
113124
* Register callback to use as replacement for calling process.exit.
114125
*/

0 commit comments

Comments
 (0)