Compare commits
2 Commits
a33500f6d4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c0e96f99a8 | |||
| c1dbcd90a4 |
13
cliutils.nim
13
cliutils.nim
@@ -22,15 +22,16 @@ 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]{1,2})?)?[m|K]"
|
||||
let STRIP_ANSI_REGEX = re"\x1B\[([0-9]{1,2}(;[0-9]{0,2})?)?[m|K]"
|
||||
return str.replace(STRIP_ANSI_REGEX, "")
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Package
|
||||
|
||||
version = "0.10.0"
|
||||
version = "0.10.2"
|
||||
author = "Jonathan Bernard"
|
||||
description = "Helper functions for writing command line interfaces."
|
||||
license = "MIT"
|
||||
|
||||
Reference in New Issue
Block a user