Skip to content

Commit 0887330

Browse files
committed
better color handling
1 parent 5369852 commit 0887330

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import chalk from "chalk"
33
import merge from "lodash/merge"
44
import path from "path"
5-
import { ArrayOr, asArray, color, COLOR_CODE_LEN, wrap } from "./utils"
5+
import { ArrayOr, asArray, color, colorCount, COLOR_CODE_LEN, wrap } from "./utils"
66

77
export function massarg() {
88
return new Massarg()
@@ -58,7 +58,7 @@ export class Massarg<Options extends OptionsBase = OptionsBase> {
5858
normalColors: "dim",
5959
highlightColors: "yellow",
6060
titleColors: "white",
61-
subtitleColors: "dim",
61+
subtitleColors: ["bold", "dim"],
6262
printWidth: 80,
6363
header: "",
6464
footer: "",
@@ -229,7 +229,7 @@ export class Massarg<Options extends OptionsBase = OptionsBase> {
229229

230230
for (const line of wrap(cmdName + cmdDescr, {
231231
indent: nameFullSize + INDENT_LEN,
232-
colorCount: COLOR_COUNT,
232+
colorCount: colorCount(normalColors, highlightColors),
233233
firstLineIndent: INDENT_LEN,
234234
printWidth: this._help.printWidth,
235235
})) {

src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export function color(color: ArrayOr<keyof typeof chalk>, ...text: any[]): strin
1111
return chalk.reset(output)
1212
}
1313

14+
export function colorCount(...colors: any[]): number {
15+
return asArray(colors).reduce((all, colorSet) => all + asArray(colorSet).length, 0)
16+
}
17+
1418
export interface WrapOptions {
1519
indent?: number
1620
firstLineIndent?: number

0 commit comments

Comments
 (0)