Skip to content

Commit

Permalink
Add addHelpOption and remove old signature for addHelpCommand (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn authored Jan 29, 2024
1 parent d891360 commit d0e9479
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,16 +603,13 @@ export class CommanderError extends Error {

/**
* Add prepared custom help command.
*
* @returns `this` command for chaining
*/
addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this;
addHelpCommand(cmd: Command): this;
/** @deprecated since v12, instead use helpCommand */
addHelpCommand(nameAndArgs: string, description?: string): this;
/** @deprecated since v12, instead use helpCommand */
addHelpCommand(enable?: boolean): this;

/**
* Add hook for life cycle event.
*/
Expand Down Expand Up @@ -1033,6 +1030,12 @@ export class CommanderError extends Error {
*/
helpOption(flags?: string | boolean, description?: string): this;

/**
* Supply your own option to use for the built-in help option.
* This is an alternative to using helpOption() to customise the flags and description etc.
*/
addHelpOption(option: Option): this;

/**
* Output help information and exit.
*
Expand Down
3 changes: 3 additions & 0 deletions tests/commander.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ expectChainedCommand(program.helpOption('-h,--help', 'custom description'));
expectChainedCommand(program.helpOption(undefined, 'custom description'));
expectChainedCommand(program.helpOption(false));

// addHelpOption
expectType<commander.Command>(program.addHelpOption(new commander.Option('-h,--help')));

// addHelpText
expectChainedCommand(program.addHelpText('after', 'text'));
expectChainedCommand(program.addHelpText('afterAll', 'text'));
Expand Down

0 comments on commit d0e9479

Please sign in to comment.