Skip to content

Commit 07723b6

Browse files
authored
Add option for Help Configuration (#1150)
Add option for Help Configuration using the `.configureHelp()` function in commander js https://github.com/tj/commander.js/tree/v11.1.0?tab=readme-ov-file#more-configuration-2
2 parents 0c60cd1 + 1cdac14 commit 07723b6

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

.changeset/twelve-rabbits-nail.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'nest-commander': minor
3+
---
4+
5+
feat: Add option for Help Configuration using the .configureHelp() function in
6+
commander js

packages/nest-commander/src/command-factory.interface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LoggerService, LogLevel } from '@nestjs/common';
22
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
3-
import { OutputConfiguration } from 'commander';
3+
import { Help, OutputConfiguration } from 'commander';
44
import type { CompletionFactoryOptions } from './completion.factory.interface';
55

66
export type ErrorHandler = (err: Error) => void;
@@ -22,6 +22,7 @@ export interface CommandFactoryRunOptions
2222
enablePositionalOptions?: boolean;
2323
enablePassThroughOptions?: boolean;
2424
outputConfiguration?: OutputConfiguration;
25+
helpConfiguration?: Help;
2526
version?: string;
2627

2728
/**

packages/nest-commander/src/command-runner.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ ${cliPluginError(
5454
this.options.pluginsAvailable,
5555
)}`);
5656
}
57+
if (this.options.helpConfiguration) {
58+
this.commander.configureHelp(this.options.helpConfiguration);
59+
}
5760
if (this.options.errorHandler) {
5861
this.commander.exitOverride(this.options.errorHandler);
5962
}
@@ -134,6 +137,9 @@ ${cliPluginError(
134137
if (this.options.outputConfiguration) {
135138
newCommand.configureOutput(this.options.outputConfiguration);
136139
}
140+
if (this.options.helpConfiguration) {
141+
newCommand.configureHelp(this.options.helpConfiguration);
142+
}
137143
if (command.command.arguments) {
138144
this.mapArgumentDescriptions(
139145
newCommand,

packages/nest-commander/src/command.factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export class CommandFactory {
9898
options.enablePassThroughOptions || false;
9999
options.outputConfiguration = options.outputConfiguration || undefined;
100100
options.completion = options.completion || false;
101+
options.helpConfiguration = options.helpConfiguration || undefined;
101102

102103
return options as DefinedCommandFactoryRunOptions;
103104
}

0 commit comments

Comments
 (0)