aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/mitchellh/cli/ui_colored.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mitchellh/cli/ui_colored.go')
-rw-r--r--vendor/github.com/mitchellh/cli/ui_colored.go32
1 files changed, 18 insertions, 14 deletions
diff --git a/vendor/github.com/mitchellh/cli/ui_colored.go b/vendor/github.com/mitchellh/cli/ui_colored.go
index e3d5131..b0ec448 100644
--- a/vendor/github.com/mitchellh/cli/ui_colored.go
+++ b/vendor/github.com/mitchellh/cli/ui_colored.go
@@ -1,7 +1,11 @@
1package cli 1package cli
2 2
3import ( 3import (
4 "fmt" 4 "github.com/fatih/color"
5)
6
7const (
8 noColor = -1
5) 9)
6 10
7// UiColor is a posix shell color code to use. 11// UiColor is a posix shell color code to use.
@@ -12,13 +16,13 @@ type UiColor struct {
12 16
13// A list of colors that are useful. These are all non-bolded by default. 17// A list of colors that are useful. These are all non-bolded by default.
14var ( 18var (
15 UiColorNone UiColor = UiColor{-1, false} 19 UiColorNone UiColor = UiColor{noColor, false}
16 UiColorRed = UiColor{31, false} 20 UiColorRed = UiColor{int(color.FgHiRed), false}
17 UiColorGreen = UiColor{32, false} 21 UiColorGreen = UiColor{int(color.FgHiGreen), false}
18 UiColorYellow = UiColor{33, false} 22 UiColorYellow = UiColor{int(color.FgHiYellow), false}
19 UiColorBlue = UiColor{34, false} 23 UiColorBlue = UiColor{int(color.FgHiBlue), false}
20 UiColorMagenta = UiColor{35, false} 24 UiColorMagenta = UiColor{int(color.FgHiMagenta), false}
21 UiColorCyan = UiColor{36, false} 25 UiColorCyan = UiColor{int(color.FgHiCyan), false}
22) 26)
23 27
24// ColoredUi is a Ui implementation that colors its output according 28// ColoredUi is a Ui implementation that colors its output according
@@ -55,15 +59,15 @@ func (u *ColoredUi) Warn(message string) {
55 u.Ui.Warn(u.colorize(message, u.WarnColor)) 59 u.Ui.Warn(u.colorize(message, u.WarnColor))
56} 60}
57 61
58func (u *ColoredUi) colorize(message string, color UiColor) string { 62func (u *ColoredUi) colorize(message string, uc UiColor) string {
59 if color.Code == -1 { 63 if uc.Code == noColor {
60 return message 64 return message
61 } 65 }
62 66
63 attr := 0 67 attr := []color.Attribute{color.Attribute(uc.Code)}
64 if color.Bold { 68 if uc.Bold {
65 attr = 1 69 attr = append(attr, color.Bold)
66 } 70 }
67 71
68 return fmt.Sprintf("\033[%d;%dm%s\033[0m", attr, color.Code, message) 72 return color.New(attr...).SprintFunc()(message)
69} 73}