summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-11 21:27:41 +0300
committerWolfy-J <[email protected]>2018-06-11 21:27:41 +0300
commitb9f800762fd642477fe45d4ef3c68f3a33ad7b6a (patch)
tree94f30690a2508810fdb7138935b064bfa606ddc3 /cmd
parent513e29f7b0b22c2eb03a374547894901950ab622 (diff)
no library dependency
Diffstat (limited to 'cmd')
-rw-r--r--cmd/rr/debug/listener.go2
-rw-r--r--cmd/rr/utils/cprint.go24
2 files changed, 11 insertions, 15 deletions
diff --git a/cmd/rr/debug/listener.go b/cmd/rr/debug/listener.go
index 5239538b..393e2b2e 100644
--- a/cmd/rr/debug/listener.go
+++ b/cmd/rr/debug/listener.go
@@ -89,5 +89,5 @@ func statusColor(status int) string {
return utils.Sprintf("<yellow>%v</reset>", status)
}
- return utils.Sprintf("<red+hb>%v</reset>", status)
+ return utils.Sprintf("<red>%v</reset>", status)
}
diff --git a/cmd/rr/utils/cprint.go b/cmd/rr/utils/cprint.go
index f6f828f8..eb1aa0ad 100644
--- a/cmd/rr/utils/cprint.go
+++ b/cmd/rr/utils/cprint.go
@@ -2,11 +2,17 @@ package utils
import (
"fmt"
- "gopkg.in/AlecAivazis/survey.v1/core"
"regexp"
"strings"
+ "github.com/mgutz/ansi"
)
+var reg *regexp.Regexp
+
+func init() {
+ reg, _ = regexp.Compile(`<([^>]+)>`)
+}
+
// Printf works identically to fmt.Print but adds `<white+hb>color formatting support for CLI</reset>`.
func Printf(format string, args ...interface{}) {
fmt.Print(Sprintf(format, args...))
@@ -14,19 +20,9 @@ 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 {
- r, err := regexp.Compile(`<([^>]+)>`)
- if err != nil {
- panic(err)
- }
-
- format = r.ReplaceAllStringFunc(format, func(s string) string {
- return fmt.Sprintf(`{{color "%s"}}`, strings.Trim(s, "<>/"))
+ format = reg.ReplaceAllStringFunc(format, func(s string) string {
+ return ansi.ColorCode(strings.Trim(s, "<>/"))
})
- out, err := core.RunTemplate(fmt.Sprintf(format, args...), nil)
- if err != nil {
- panic(err)
- }
-
- return out
+ return fmt.Sprintf(format, args...)
}