Skip to content

Commit 66f48d8

Browse files
committed
feat(help): weaken the color of deprecated commands and options
1 parent 4acda7d commit 66f48d8

File tree

1 file changed

+9
-3
lines changed
  • packages/@ionic/cli-framework/src/lib

1 file changed

+9
-3
lines changed

packages/@ionic/cli-framework/src/lib/help.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { isHydratedCommandMetadata } from '../guards';
77
import { filter, map } from '../utils/array';
88
import { generateFillSpaceStringList, stringWidth, wordWrap } from '../utils/format';
99

10-
import { Colors, DEFAULT_COLORS } from './colors';
10+
import { ColorFunction, Colors, DEFAULT_COLORS } from './colors';
1111
import { formatOptionName, hydrateOptionSpec } from './options';
1212
import { validators } from './validators';
1313

@@ -224,14 +224,18 @@ export class NamespaceStringHelpFormatter<C extends ICommand<C, N, M, I, O>, N e
224224
const fillStringArray = generateFillSpaceStringList(fullCmd, this.dotswidth, weak('.'));
225225

226226
const formattedCommands = await Promise.all(commands.map(async (cmd, index) => {
227+
const wrapColor: ColorFunction = cmd.groups && cmd.groups.includes(CommandGroup.Deprecated) ? weak : lodash.identity;
228+
227229
const summary = (
228230
(await this.formatBeforeCommandSummary(cmd)) +
229231
cmd.summary +
230232
(await this.formatAfterCommandSummary(cmd))
231233
);
232234

233235
const wrappedSummary = wordWrap(summary, { indentation: this.dotswidth + 6 });
234-
return `${input(lodash.tail(cmd.path).map(([p]) => p).join(' '))}${wrappedSummary ? ' ' + fillStringArray[index] + ' ' + wrappedSummary : ''}`;
236+
const line = `${input(lodash.tail(cmd.path).map(([p]) => p).join(' '))}${wrappedSummary ? ' ' + fillStringArray[index] + ' ' + wrappedSummary : ''}`;
237+
238+
return wrapColor(line);
235239
}));
236240

237241
return formattedCommands;
@@ -481,6 +485,7 @@ export class CommandStringHelpFormatter<C extends ICommand<C, N, M, I, O>, N ext
481485

482486
async formatOptionLine(opt: O) {
483487
const { weak } = this.colors;
488+
const wrapColor: ColorFunction = opt.groups && opt.groups.includes(OptionGroup.Deprecated) ? weak : lodash.identity;
484489
const optionName = formatOptionName(opt, { colors: this.colors });
485490
const optionNameLength = stringWidth(optionName);
486491
const fullLength = optionNameLength > this.dotswidth ? optionNameLength + 1 : this.dotswidth;
@@ -491,8 +496,9 @@ export class CommandStringHelpFormatter<C extends ICommand<C, N, M, I, O>, N ext
491496
);
492497

493498
const wrappedDescription = wordWrap(fullDescription, { indentation: this.dotswidth + 6 });
499+
const line = `${optionName} ${weak('.').repeat(fullLength - optionNameLength)} ${wrappedDescription}`;
494500

495-
return `${optionName} ${weak('.').repeat(fullLength - optionNameLength)} ${wrappedDescription}`;
501+
return wrapColor(line);
496502
}
497503

498504
/**

0 commit comments

Comments
 (0)