summaryrefslogtreecommitdiff
path: root/cmd/util/cprint.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-02-14 14:58:04 +0300
committerWolfy-J <[email protected]>2019-02-14 14:58:04 +0300
commita9e8ff6ac4f1a20c2024312cab65dd2c12c721e8 (patch)
tree3d8641f60a51346dbd044ced080a51e60f61434a /cmd/util/cprint.go
parentdd4bc086e18cda344b75c29175885db90c8e7196 (diff)
version bump
Diffstat (limited to 'cmd/util/cprint.go')
-rw-r--r--cmd/util/cprint.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/util/cprint.go b/cmd/util/cprint.go
index 0985de62..61199c4a 100644
--- a/cmd/util/cprint.go
+++ b/cmd/util/cprint.go
@@ -7,7 +7,10 @@ import (
"strings"
)
-var reg *regexp.Regexp
+var (
+ reg *regexp.Regexp
+ EnableColors bool
+)
func init() {
reg, _ = regexp.Compile(`<([^>]+)>`)
@@ -21,6 +24,10 @@ func Printf(format string, args ...interface{}) {
// Sprintf works identically to fmt.Sprintf but adds `<white+hb>color formatting support for CLI</reset>`.
func Sprintf(format string, args ...interface{}) string {
format = reg.ReplaceAllStringFunc(format, func(s string) string {
+ if !EnableColors {
+ return ""
+ }
+
return ansi.ColorCode(strings.Trim(s, "<>/"))
})