Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add method to hide option extras #2156

Merged
merged 10 commits into from Dec 28, 2022
Merged
9 changes: 8 additions & 1 deletion lib/usage.ts
Expand Up @@ -443,7 +443,8 @@ export function usage(yargs: YargsInstance, shim: PlatformShim) {
desc
);

if (extra) ui.div({text: extra, padding: [0, 0, 0, 2], align: 'right'});
if (extra && !shouldHideOptionExtras)
ui.div({text: extra, padding: [0, 0, 0, 2], align: 'right'});
else ui.div();
});

Expand Down Expand Up @@ -734,6 +735,11 @@ export function usage(yargs: YargsInstance, shim: PlatformShim) {
}
};

let shouldHideOptionExtras = false;
self.hideOptionExtras = function hideOptionExtras() {
shouldHideOptionExtras = true;
};

return self;
}

Expand Down Expand Up @@ -763,6 +769,7 @@ export interface UsageInstance {
getUsage(): [string, string][];
getUsageDisabled(): boolean;
help(): string;
hideOptionExtras(): void;
reset(localLookup: Dictionary<boolean>): UsageInstance;
showHelp(level?: 'error' | 'log' | ((message: string) => void)): void;
showHelpOnFail(enabled?: boolean | string, message?: string): UsageInstance;
Expand Down
4 changes: 4 additions & 0 deletions lib/yargs-factory.ts
Expand Up @@ -843,6 +843,10 @@ export class YargsInstance {
this.#options.hiddenOptions.push(key);
return this;
}
hideOptionExtras(): YargsInstance {
this.#usage.hideOptionExtras();
return this;
}
implies(
key: string | Dictionary<KeyOrPos | KeyOrPos[]>,
value?: KeyOrPos | KeyOrPos[]
Expand Down