diff --git a/typings/commander-tests.ts b/typings/commander-tests.ts index d7914dd73..ff0e2edb7 100644 --- a/typings/commander-tests.ts +++ b/typings/commander-tests.ts @@ -55,6 +55,13 @@ const addCommandThis: commander.Command = program.addCommand(new commander.Comma // arguments const argumentsThis: commander.Command = program.arguments(' [env]'); +// addHelpCommand +const addHelpCommandThis1: commander.Command = program.addHelpCommand(); +const addHelpCommandThis3: commander.Command = program.addHelpCommand(false); +const addHelpCommandThis2: commander.Command = program.addHelpCommand(true); +const addHelpCommandThis4: commander.Command = program.addHelpCommand('compress '); +const addHelpCommandThis5: commander.Command = program.addHelpCommand('compress ', 'compress target file'); + // exitOverride const exitThis1: commander.Command = program.exitOverride(); const exitThis2: commander.Command = program.exitOverride((err): never => { diff --git a/typings/index.d.ts b/typings/index.d.ts index e404ae88d..25a0de1d2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -109,6 +109,17 @@ declare namespace commander { */ arguments(desc: string): this; + /** + * Override default decision whether to add implicit help command. + * + * addHelpCommand() // force on + * addHelpCommand(false); // force off + * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details + * + * @returns `this` command for chaining + */ + addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this; + /** * Register callback to use as replacement for calling process.exit. */