From 7320fff4860fe788674e672e6c284340fdc48918 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Wed, 2 Oct 2024 10:40:12 -0600 Subject: [PATCH] fix: add respectNoCacheDefault to help options --- src/help/command.ts | 3 ++- src/interfaces/help.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/help/command.ts b/src/help/command.ts index 239e3b957..951bf3b1b 100644 --- a/src/help/command.ts +++ b/src/help/command.ts @@ -188,7 +188,8 @@ export class CommandHelp extends HelpFormatter { if (noChar) left = left.replace(' ', '') let right = flag.summary || flag.description || '' - if (flag.type === 'option' && flag.default) { + const canBeCached = !(this.opts.respectNoCacheDefault === true && flag.noCacheDefault === true) + if (flag.type === 'option' && flag.default && canBeCached) { right = `${colorize(this.config?.theme?.flagDefaultValue, `[default: ${flag.default}]`)} ${right}` } diff --git a/src/interfaces/help.ts b/src/interfaces/help.ts index 370dac772..33709b4be 100644 --- a/src/interfaces/help.ts +++ b/src/interfaces/help.ts @@ -24,6 +24,10 @@ export interface HelpOptions { */ hideCommandSummaryInDescription?: boolean maxWidth: number + /** + * Respect the `noCacheDefault` property on flags. Defaults to false. + */ + respectNoCacheDefault?: boolean /** * Only show the help for the specified sections. Defaults to all sections. */