From c0e96f99a85f6fb80e8d399cfda76134e36b2292 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Wed, 19 Nov 2025 16:55:54 -0600 Subject: [PATCH] Add termFmt to increase capabilities from withColor. --- cliutils.nim | 11 ++++++----- cliutils.nimble | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cliutils.nim b/cliutils.nim index 5f1b7ba..d581198 100644 --- a/cliutils.nim +++ b/cliutils.nim @@ -22,12 +22,13 @@ proc termColor*(color: TermColor, bright, bold = false): string = return "\e[" & $colorVal & (if bold: ";1" else: "") & "m" -proc withColor*(str: string, color: TermColor, bright, bold, skipReset = false): string = - if skipReset: - return termColor(color, bright, bold) & str - else: - return termColor(color, bright, bold) & str & termReset +proc termFmt*(str: string, color: TermColor, bright, bold, underline, skipReset = false): string = + result = termColor(color, bright, bold) & str + if underline: result = "\e[4m" & result + if not skipReset: result &= termReset +proc withColor*(str: string, color: TermColor, bright, bold, skipReset = false): string = + termFmt(str, color, bright, bold, false, skipReset) proc stripAnsi*(str: string): string = let STRIP_ANSI_REGEX = re"\x1B\[([0-9]{1,2}(;[0-9]{0,2})?)?[m|K]" diff --git a/cliutils.nimble b/cliutils.nimble index ba528a6..a45958f 100644 --- a/cliutils.nimble +++ b/cliutils.nimble @@ -1,6 +1,6 @@ # Package -version = "0.10.1" +version = "0.10.2" author = "Jonathan Bernard" description = "Helper functions for writing command line interfaces." license = "MIT"