diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/mitchellh/cli/ui_colored.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip |
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/mitchellh/cli/ui_colored.go')
-rw-r--r-- | vendor/github.com/mitchellh/cli/ui_colored.go | 32 |
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 @@ | |||
1 | package cli | 1 | package cli |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "github.com/fatih/color" |
5 | ) | ||
6 | |||
7 | const ( | ||
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. |
14 | var ( | 18 | var ( |
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 | ||
58 | func (u *ColoredUi) colorize(message string, color UiColor) string { | 62 | func (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 | } |