Skip to content

Commit 7306e08

Browse files
committed
chore: rename style utils
1 parent 058e6c8 commit 7306e08

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/help.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import z from 'zod'
2-
import { format, StringStyle, stripColors } from './color'
2+
import { format, StringStyle, stripStyle } from './style'
33
import { MassargCommand } from './command'
44
import { DeepRequired, strConcat, indent } from './utils'
55

@@ -242,7 +242,7 @@ export class HelpGenerator {
242242
}
243243

244244
function wrap(text: string, maxRowLength: number): string {
245-
const length = stripColors(text).length
245+
const length = stripStyle(text).length
246246
if (length <= maxRowLength) {
247247
return text
248248
}
@@ -251,7 +251,7 @@ function wrap(text: string, maxRowLength: number): string {
251251
let currentRow = ''
252252

253253
for (const word of words) {
254-
if (stripColors(currentRow).length + stripColors(word).length + 1 > maxRowLength) {
254+
if (stripStyle(currentRow).length + stripStyle(word).length + 1 > maxRowLength) {
255255
subRows.push(currentRow)
256256
currentRow = ''
257257
}
@@ -288,7 +288,7 @@ function generateHelpTable<T extends Partial<GenerateTableCommandConfig>>(
288288
const table = rows.map((row) => {
289289
const name = nameStyle(row.name.padEnd(maxNameLength + 2))
290290
const description = descStyle(row.description)
291-
const length = stripColors(name).length + stripColors(description).length
291+
const length = stripStyle(name).length + stripStyle(description).length
292292
if (length <= maxRowLength) {
293293
const line = `${name}${description}`
294294
if (!compact) {
@@ -301,7 +301,7 @@ function generateHelpTable<T extends Partial<GenerateTableCommandConfig>>(
301301
let currentRow = name
302302

303303
for (const word of words) {
304-
if (stripColors(currentRow).length + stripColors(word).length + 1 > maxRowLength) {
304+
if (stripStyle(currentRow).length + stripStyle(word).length + 1 > maxRowLength) {
305305
subRows.push(currentRow)
306306
currentRow = ' '.repeat(maxNameLength + 2)
307307
}

src/color.ts renamed to src/style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export function format(string: string, style: StringStyle = {}): string {
4545
return `${colorCode}${boldCode}${underlineCode}${string}${resetCode}`
4646
}
4747

48-
export function stripColors(string: string): string {
48+
export function stripStyle(string: string): string {
4949
return string.replace(/\x1b\[\d+m/gi, '')
5050
}

0 commit comments

Comments
 (0)