aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/fatih
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/fatih
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-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/fatih')
-rw-r--r--vendor/github.com/fatih/color/.travis.yml5
-rw-r--r--vendor/github.com/fatih/color/Gopkg.lock27
-rw-r--r--vendor/github.com/fatih/color/Gopkg.toml30
-rw-r--r--vendor/github.com/fatih/color/LICENSE.md20
-rw-r--r--vendor/github.com/fatih/color/README.md179
-rw-r--r--vendor/github.com/fatih/color/color.go603
-rw-r--r--vendor/github.com/fatih/color/doc.go133
7 files changed, 997 insertions, 0 deletions
diff --git a/vendor/github.com/fatih/color/.travis.yml b/vendor/github.com/fatih/color/.travis.yml
new file mode 100644
index 0000000..95f8a1f
--- /dev/null
+++ b/vendor/github.com/fatih/color/.travis.yml
@@ -0,0 +1,5 @@
1language: go
2go:
3 - 1.8.x
4 - tip
5
diff --git a/vendor/github.com/fatih/color/Gopkg.lock b/vendor/github.com/fatih/color/Gopkg.lock
new file mode 100644
index 0000000..7d879e9
--- /dev/null
+++ b/vendor/github.com/fatih/color/Gopkg.lock
@@ -0,0 +1,27 @@
1# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
2
3
4[[projects]]
5 name = "github.com/mattn/go-colorable"
6 packages = ["."]
7 revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
8 version = "v0.0.9"
9
10[[projects]]
11 name = "github.com/mattn/go-isatty"
12 packages = ["."]
13 revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
14 version = "v0.0.3"
15
16[[projects]]
17 branch = "master"
18 name = "golang.org/x/sys"
19 packages = ["unix"]
20 revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd"
21
22[solve-meta]
23 analyzer-name = "dep"
24 analyzer-version = 1
25 inputs-digest = "e8a50671c3cb93ea935bf210b1cd20702876b9d9226129be581ef646d1565cdc"
26 solver-name = "gps-cdcl"
27 solver-version = 1
diff --git a/vendor/github.com/fatih/color/Gopkg.toml b/vendor/github.com/fatih/color/Gopkg.toml
new file mode 100644
index 0000000..ff1617f
--- /dev/null
+++ b/vendor/github.com/fatih/color/Gopkg.toml
@@ -0,0 +1,30 @@
1
2# Gopkg.toml example
3#
4# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
5# for detailed Gopkg.toml documentation.
6#
7# required = ["github.com/user/thing/cmd/thing"]
8# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
9#
10# [[constraint]]
11# name = "github.com/user/project"
12# version = "1.0.0"
13#
14# [[constraint]]
15# name = "github.com/user/project2"
16# branch = "dev"
17# source = "github.com/myfork/project2"
18#
19# [[override]]
20# name = "github.com/x/y"
21# version = "2.4.0"
22
23
24[[constraint]]
25 name = "github.com/mattn/go-colorable"
26 version = "0.0.9"
27
28[[constraint]]
29 name = "github.com/mattn/go-isatty"
30 version = "0.0.3"
diff --git a/vendor/github.com/fatih/color/LICENSE.md b/vendor/github.com/fatih/color/LICENSE.md
new file mode 100644
index 0000000..25fdaf6
--- /dev/null
+++ b/vendor/github.com/fatih/color/LICENSE.md
@@ -0,0 +1,20 @@
1The MIT License (MIT)
2
3Copyright (c) 2013 Fatih Arslan
4
5Permission is hereby granted, free of charge, to any person obtaining a copy of
6this software and associated documentation files (the "Software"), to deal in
7the Software without restriction, including without limitation the rights to
8use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all
13copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/fatih/color/README.md b/vendor/github.com/fatih/color/README.md
new file mode 100644
index 0000000..3fc9544
--- /dev/null
+++ b/vendor/github.com/fatih/color/README.md
@@ -0,0 +1,179 @@
1# Color [![GoDoc](https://godoc.org/github.com/fatih/color?status.svg)](https://godoc.org/github.com/fatih/color) [![Build Status](https://img.shields.io/travis/fatih/color.svg?style=flat-square)](https://travis-ci.org/fatih/color)
2
3
4
5Color lets you use colorized outputs in terms of [ANSI Escape
6Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It
7has support for Windows too! The API can be used in several ways, pick one that
8suits you.
9
10
11![Color](https://i.imgur.com/c1JI0lA.png)
12
13
14## Install
15
16```bash
17go get github.com/fatih/color
18```
19
20Note that the `vendor` folder is here for stability. Remove the folder if you
21already have the dependencies in your GOPATH.
22
23## Examples
24
25### Standard colors
26
27```go
28// Print with default helper functions
29color.Cyan("Prints text in cyan.")
30
31// A newline will be appended automatically
32color.Blue("Prints %s in blue.", "text")
33
34// These are using the default foreground colors
35color.Red("We have red")
36color.Magenta("And many others ..")
37
38```
39
40### Mix and reuse colors
41
42```go
43// Create a new color object
44c := color.New(color.FgCyan).Add(color.Underline)
45c.Println("Prints cyan text with an underline.")
46
47// Or just add them to New()
48d := color.New(color.FgCyan, color.Bold)
49d.Printf("This prints bold cyan %s\n", "too!.")
50
51// Mix up foreground and background colors, create new mixes!
52red := color.New(color.FgRed)
53
54boldRed := red.Add(color.Bold)
55boldRed.Println("This will print text in bold red.")
56
57whiteBackground := red.Add(color.BgWhite)
58whiteBackground.Println("Red text with white background.")
59```
60
61### Use your own output (io.Writer)
62
63```go
64// Use your own io.Writer output
65color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
66
67blue := color.New(color.FgBlue)
68blue.Fprint(writer, "This will print text in blue.")
69```
70
71### Custom print functions (PrintFunc)
72
73```go
74// Create a custom print function for convenience
75red := color.New(color.FgRed).PrintfFunc()
76red("Warning")
77red("Error: %s", err)
78
79// Mix up multiple attributes
80notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
81notice("Don't forget this...")
82```
83
84### Custom fprint functions (FprintFunc)
85
86```go
87blue := color.New(FgBlue).FprintfFunc()
88blue(myWriter, "important notice: %s", stars)
89
90// Mix up with multiple attributes
91success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
92success(myWriter, "Don't forget this...")
93```
94
95### Insert into noncolor strings (SprintFunc)
96
97```go
98// Create SprintXxx functions to mix strings with other non-colorized strings:
99yellow := color.New(color.FgYellow).SprintFunc()
100red := color.New(color.FgRed).SprintFunc()
101fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error"))
102
103info := color.New(color.FgWhite, color.BgGreen).SprintFunc()
104fmt.Printf("This %s rocks!\n", info("package"))
105
106// Use helper functions
107fmt.Println("This", color.RedString("warning"), "should be not neglected.")
108fmt.Printf("%v %v\n", color.GreenString("Info:"), "an important message.")
109
110// Windows supported too! Just don't forget to change the output to color.Output
111fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
112```
113
114### Plug into existing code
115
116```go
117// Use handy standard colors
118color.Set(color.FgYellow)
119
120fmt.Println("Existing text will now be in yellow")
121fmt.Printf("This one %s\n", "too")
122
123color.Unset() // Don't forget to unset
124
125// You can mix up parameters
126color.Set(color.FgMagenta, color.Bold)
127defer color.Unset() // Use it in your function
128
129fmt.Println("All text will now be bold magenta.")
130```
131
132### Disable/Enable color
133
134There might be a case where you want to explicitly disable/enable color output. the
135`go-isatty` package will automatically disable color output for non-tty output streams
136(for example if the output were piped directly to `less`)
137
138`Color` has support to disable/enable colors both globally and for single color
139definitions. For example suppose you have a CLI app and a `--no-color` bool flag. You
140can easily disable the color output with:
141
142```go
143
144var flagNoColor = flag.Bool("no-color", false, "Disable color output")
145
146if *flagNoColor {
147 color.NoColor = true // disables colorized output
148}
149```
150
151It also has support for single color definitions (local). You can
152disable/enable color output on the fly:
153
154```go
155c := color.New(color.FgCyan)
156c.Println("Prints cyan text")
157
158c.DisableColor()
159c.Println("This is printed without any color")
160
161c.EnableColor()
162c.Println("This prints again cyan...")
163```
164
165## Todo
166
167* Save/Return previous values
168* Evaluate fmt.Formatter interface
169
170
171## Credits
172
173 * [Fatih Arslan](https://github.com/fatih)
174 * Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable)
175
176## License
177
178The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details
179
diff --git a/vendor/github.com/fatih/color/color.go b/vendor/github.com/fatih/color/color.go
new file mode 100644
index 0000000..91c8e9f
--- /dev/null
+++ b/vendor/github.com/fatih/color/color.go
@@ -0,0 +1,603 @@
1package color
2
3import (
4 "fmt"
5 "io"
6 "os"
7 "strconv"
8 "strings"
9 "sync"
10
11 "github.com/mattn/go-colorable"
12 "github.com/mattn/go-isatty"
13)
14
15var (
16 // NoColor defines if the output is colorized or not. It's dynamically set to
17 // false or true based on the stdout's file descriptor referring to a terminal
18 // or not. This is a global option and affects all colors. For more control
19 // over each color block use the methods DisableColor() individually.
20 NoColor = os.Getenv("TERM") == "dumb" ||
21 (!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
22
23 // Output defines the standard output of the print functions. By default
24 // os.Stdout is used.
25 Output = colorable.NewColorableStdout()
26
27 // Error defines a color supporting writer for os.Stderr.
28 Error = colorable.NewColorableStderr()
29
30 // colorsCache is used to reduce the count of created Color objects and
31 // allows to reuse already created objects with required Attribute.
32 colorsCache = make(map[Attribute]*Color)
33 colorsCacheMu sync.Mutex // protects colorsCache
34)
35
36// Color defines a custom color object which is defined by SGR parameters.
37type Color struct {
38 params []Attribute
39 noColor *bool
40}
41
42// Attribute defines a single SGR Code
43type Attribute int
44
45const escape = "\x1b"
46
47// Base attributes
48const (
49 Reset Attribute = iota
50 Bold
51 Faint
52 Italic
53 Underline
54 BlinkSlow
55 BlinkRapid
56 ReverseVideo
57 Concealed
58 CrossedOut
59)
60
61// Foreground text colors
62const (
63 FgBlack Attribute = iota + 30
64 FgRed
65 FgGreen
66 FgYellow
67 FgBlue
68 FgMagenta
69 FgCyan
70 FgWhite
71)
72
73// Foreground Hi-Intensity text colors
74const (
75 FgHiBlack Attribute = iota + 90
76 FgHiRed
77 FgHiGreen
78 FgHiYellow
79 FgHiBlue
80 FgHiMagenta
81 FgHiCyan
82 FgHiWhite
83)
84
85// Background text colors
86const (
87 BgBlack Attribute = iota + 40
88 BgRed
89 BgGreen
90 BgYellow
91 BgBlue
92 BgMagenta
93 BgCyan
94 BgWhite
95)
96
97// Background Hi-Intensity text colors
98const (
99 BgHiBlack Attribute = iota + 100
100 BgHiRed
101 BgHiGreen
102 BgHiYellow
103 BgHiBlue
104 BgHiMagenta
105 BgHiCyan
106 BgHiWhite
107)
108
109// New returns a newly created color object.
110func New(value ...Attribute) *Color {
111 c := &Color{params: make([]Attribute, 0)}
112 c.Add(value...)
113 return c
114}
115
116// Set sets the given parameters immediately. It will change the color of
117// output with the given SGR parameters until color.Unset() is called.
118func Set(p ...Attribute) *Color {
119 c := New(p...)
120 c.Set()
121 return c
122}
123
124// Unset resets all escape attributes and clears the output. Usually should
125// be called after Set().
126func Unset() {
127 if NoColor {
128 return
129 }
130
131 fmt.Fprintf(Output, "%s[%dm", escape, Reset)
132}
133
134// Set sets the SGR sequence.
135func (c *Color) Set() *Color {
136 if c.isNoColorSet() {
137 return c
138 }
139
140 fmt.Fprintf(Output, c.format())
141 return c
142}
143
144func (c *Color) unset() {
145 if c.isNoColorSet() {
146 return
147 }
148
149 Unset()
150}
151
152func (c *Color) setWriter(w io.Writer) *Color {
153 if c.isNoColorSet() {
154 return c
155 }
156
157 fmt.Fprintf(w, c.format())
158 return c
159}
160
161func (c *Color) unsetWriter(w io.Writer) {
162 if c.isNoColorSet() {
163 return
164 }
165
166 if NoColor {
167 return
168 }
169
170 fmt.Fprintf(w, "%s[%dm", escape, Reset)
171}
172
173// Add is used to chain SGR parameters. Use as many as parameters to combine
174// and create custom color objects. Example: Add(color.FgRed, color.Underline).
175func (c *Color) Add(value ...Attribute) *Color {
176 c.params = append(c.params, value...)
177 return c
178}
179
180func (c *Color) prepend(value Attribute) {
181 c.params = append(c.params, 0)
182 copy(c.params[1:], c.params[0:])
183 c.params[0] = value
184}
185
186// Fprint formats using the default formats for its operands and writes to w.
187// Spaces are added between operands when neither is a string.
188// It returns the number of bytes written and any write error encountered.
189// On Windows, users should wrap w with colorable.NewColorable() if w is of
190// type *os.File.
191func (c *Color) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
192 c.setWriter(w)
193 defer c.unsetWriter(w)
194
195 return fmt.Fprint(w, a...)
196}
197
198// Print formats using the default formats for its operands and writes to
199// standard output. Spaces are added between operands when neither is a
200// string. It returns the number of bytes written and any write error
201// encountered. This is the standard fmt.Print() method wrapped with the given
202// color.
203func (c *Color) Print(a ...interface{}) (n int, err error) {
204 c.Set()
205 defer c.unset()
206
207 return fmt.Fprint(Output, a...)
208}
209
210// Fprintf formats according to a format specifier and writes to w.
211// It returns the number of bytes written and any write error encountered.
212// On Windows, users should wrap w with colorable.NewColorable() if w is of
213// type *os.File.
214func (c *Color) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
215 c.setWriter(w)
216 defer c.unsetWriter(w)
217
218 return fmt.Fprintf(w, format, a...)
219}
220
221// Printf formats according to a format specifier and writes to standard output.
222// It returns the number of bytes written and any write error encountered.
223// This is the standard fmt.Printf() method wrapped with the given color.
224func (c *Color) Printf(format string, a ...interface{}) (n int, err error) {
225 c.Set()
226 defer c.unset()
227
228 return fmt.Fprintf(Output, format, a...)
229}
230
231// Fprintln formats using the default formats for its operands and writes to w.
232// Spaces are always added between operands and a newline is appended.
233// On Windows, users should wrap w with colorable.NewColorable() if w is of
234// type *os.File.
235func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
236 c.setWriter(w)
237 defer c.unsetWriter(w)
238
239 return fmt.Fprintln(w, a...)
240}
241
242// Println formats using the default formats for its operands and writes to
243// standard output. Spaces are always added between operands and a newline is
244// appended. It returns the number of bytes written and any write error
245// encountered. This is the standard fmt.Print() method wrapped with the given
246// color.
247func (c *Color) Println(a ...interface{}) (n int, err error) {
248 c.Set()
249 defer c.unset()
250
251 return fmt.Fprintln(Output, a...)
252}
253
254// Sprint is just like Print, but returns a string instead of printing it.
255func (c *Color) Sprint(a ...interface{}) string {
256 return c.wrap(fmt.Sprint(a...))
257}
258
259// Sprintln is just like Println, but returns a string instead of printing it.
260func (c *Color) Sprintln(a ...interface{}) string {
261 return c.wrap(fmt.Sprintln(a...))
262}
263
264// Sprintf is just like Printf, but returns a string instead of printing it.
265func (c *Color) Sprintf(format string, a ...interface{}) string {
266 return c.wrap(fmt.Sprintf(format, a...))
267}
268
269// FprintFunc returns a new function that prints the passed arguments as
270// colorized with color.Fprint().
271func (c *Color) FprintFunc() func(w io.Writer, a ...interface{}) {
272 return func(w io.Writer, a ...interface{}) {
273 c.Fprint(w, a...)
274 }
275}
276
277// PrintFunc returns a new function that prints the passed arguments as
278// colorized with color.Print().
279func (c *Color) PrintFunc() func(a ...interface{}) {
280 return func(a ...interface{}) {
281 c.Print(a...)
282 }
283}
284
285// FprintfFunc returns a new function that prints the passed arguments as
286// colorized with color.Fprintf().
287func (c *Color) FprintfFunc() func(w io.Writer, format string, a ...interface{}) {
288 return func(w io.Writer, format string, a ...interface{}) {
289 c.Fprintf(w, format, a...)
290 }
291}
292
293// PrintfFunc returns a new function that prints the passed arguments as
294// colorized with color.Printf().
295func (c *Color) PrintfFunc() func(format string, a ...interface{}) {
296 return func(format string, a ...interface{}) {
297 c.Printf(format, a...)
298 }
299}
300
301// FprintlnFunc returns a new function that prints the passed arguments as
302// colorized with color.Fprintln().
303func (c *Color) FprintlnFunc() func(w io.Writer, a ...interface{}) {
304 return func(w io.Writer, a ...interface{}) {
305 c.Fprintln(w, a...)
306 }
307}
308
309// PrintlnFunc returns a new function that prints the passed arguments as
310// colorized with color.Println().
311func (c *Color) PrintlnFunc() func(a ...interface{}) {
312 return func(a ...interface{}) {
313 c.Println(a...)
314 }
315}
316
317// SprintFunc returns a new function that returns colorized strings for the
318// given arguments with fmt.Sprint(). Useful to put into or mix into other
319// string. Windows users should use this in conjunction with color.Output, example:
320//
321// put := New(FgYellow).SprintFunc()
322// fmt.Fprintf(color.Output, "This is a %s", put("warning"))
323func (c *Color) SprintFunc() func(a ...interface{}) string {
324 return func(a ...interface{}) string {
325 return c.wrap(fmt.Sprint(a...))
326 }
327}
328
329// SprintfFunc returns a new function that returns colorized strings for the
330// given arguments with fmt.Sprintf(). Useful to put into or mix into other
331// string. Windows users should use this in conjunction with color.Output.
332func (c *Color) SprintfFunc() func(format string, a ...interface{}) string {
333 return func(format string, a ...interface{}) string {
334 return c.wrap(fmt.Sprintf(format, a...))
335 }
336}
337
338// SprintlnFunc returns a new function that returns colorized strings for the
339// given arguments with fmt.Sprintln(). Useful to put into or mix into other
340// string. Windows users should use this in conjunction with color.Output.
341func (c *Color) SprintlnFunc() func(a ...interface{}) string {
342 return func(a ...interface{}) string {
343 return c.wrap(fmt.Sprintln(a...))
344 }
345}
346
347// sequence returns a formatted SGR sequence to be plugged into a "\x1b[...m"
348// an example output might be: "1;36" -> bold cyan
349func (c *Color) sequence() string {
350 format := make([]string, len(c.params))
351 for i, v := range c.params {
352 format[i] = strconv.Itoa(int(v))
353 }
354
355 return strings.Join(format, ";")
356}
357
358// wrap wraps the s string with the colors attributes. The string is ready to
359// be printed.
360func (c *Color) wrap(s string) string {
361 if c.isNoColorSet() {
362 return s
363 }
364
365 return c.format() + s + c.unformat()
366}
367
368func (c *Color) format() string {
369 return fmt.Sprintf("%s[%sm", escape, c.sequence())
370}
371
372func (c *Color) unformat() string {
373 return fmt.Sprintf("%s[%dm", escape, Reset)
374}
375
376// DisableColor disables the color output. Useful to not change any existing
377// code and still being able to output. Can be used for flags like
378// "--no-color". To enable back use EnableColor() method.
379func (c *Color) DisableColor() {
380 c.noColor = boolPtr(true)
381}
382
383// EnableColor enables the color output. Use it in conjunction with
384// DisableColor(). Otherwise this method has no side effects.
385func (c *Color) EnableColor() {
386 c.noColor = boolPtr(false)
387}
388
389func (c *Color) isNoColorSet() bool {
390 // check first if we have user setted action
391 if c.noColor != nil {
392 return *c.noColor
393 }
394
395 // if not return the global option, which is disabled by default
396 return NoColor
397}
398
399// Equals returns a boolean value indicating whether two colors are equal.
400func (c *Color) Equals(c2 *Color) bool {
401 if len(c.params) != len(c2.params) {
402 return false
403 }
404
405 for _, attr := range c.params {
406 if !c2.attrExists(attr) {
407 return false
408 }
409 }
410
411 return true
412}
413
414func (c *Color) attrExists(a Attribute) bool {
415 for _, attr := range c.params {
416 if attr == a {
417 return true
418 }
419 }
420
421 return false
422}
423
424func boolPtr(v bool) *bool {
425 return &v
426}
427
428func getCachedColor(p Attribute) *Color {
429 colorsCacheMu.Lock()
430 defer colorsCacheMu.Unlock()
431
432 c, ok := colorsCache[p]
433 if !ok {
434 c = New(p)
435 colorsCache[p] = c
436 }
437
438 return c
439}
440
441func colorPrint(format string, p Attribute, a ...interface{}) {
442 c := getCachedColor(p)
443
444 if !strings.HasSuffix(format, "\n") {
445 format += "\n"
446 }
447
448 if len(a) == 0 {
449 c.Print(format)
450 } else {
451 c.Printf(format, a...)
452 }
453}
454
455func colorString(format string, p Attribute, a ...interface{}) string {
456 c := getCachedColor(p)
457
458 if len(a) == 0 {
459 return c.SprintFunc()(format)
460 }
461
462 return c.SprintfFunc()(format, a...)
463}
464
465// Black is a convenient helper function to print with black foreground. A
466// newline is appended to format by default.
467func Black(format string, a ...interface{}) { colorPrint(format, FgBlack, a...) }
468
469// Red is a convenient helper function to print with red foreground. A
470// newline is appended to format by default.
471func Red(format string, a ...interface{}) { colorPrint(format, FgRed, a...) }
472
473// Green is a convenient helper function to print with green foreground. A
474// newline is appended to format by default.
475func Green(format string, a ...interface{}) { colorPrint(format, FgGreen, a...) }
476
477// Yellow is a convenient helper function to print with yellow foreground.
478// A newline is appended to format by default.
479func Yellow(format string, a ...interface{}) { colorPrint(format, FgYellow, a...) }
480
481// Blue is a convenient helper function to print with blue foreground. A
482// newline is appended to format by default.
483func Blue(format string, a ...interface{}) { colorPrint(format, FgBlue, a...) }
484
485// Magenta is a convenient helper function to print with magenta foreground.
486// A newline is appended to format by default.
487func Magenta(format string, a ...interface{}) { colorPrint(format, FgMagenta, a...) }
488
489// Cyan is a convenient helper function to print with cyan foreground. A
490// newline is appended to format by default.
491func Cyan(format string, a ...interface{}) { colorPrint(format, FgCyan, a...) }
492
493// White is a convenient helper function to print with white foreground. A
494// newline is appended to format by default.
495func White(format string, a ...interface{}) { colorPrint(format, FgWhite, a...) }
496
497// BlackString is a convenient helper function to return a string with black
498// foreground.
499func BlackString(format string, a ...interface{}) string { return colorString(format, FgBlack, a...) }
500
501// RedString is a convenient helper function to return a string with red
502// foreground.
503func RedString(format string, a ...interface{}) string { return colorString(format, FgRed, a...) }
504
505// GreenString is a convenient helper function to return a string with green
506// foreground.
507func GreenString(format string, a ...interface{}) string { return colorString(format, FgGreen, a...) }
508
509// YellowString is a convenient helper function to return a string with yellow
510// foreground.
511func YellowString(format string, a ...interface{}) string { return colorString(format, FgYellow, a...) }
512
513// BlueString is a convenient helper function to return a string with blue
514// foreground.
515func BlueString(format string, a ...interface{}) string { return colorString(format, FgBlue, a...) }
516
517// MagentaString is a convenient helper function to return a string with magenta
518// foreground.
519func MagentaString(format string, a ...interface{}) string {
520 return colorString(format, FgMagenta, a...)
521}
522
523// CyanString is a convenient helper function to return a string with cyan
524// foreground.
525func CyanString(format string, a ...interface{}) string { return colorString(format, FgCyan, a...) }
526
527// WhiteString is a convenient helper function to return a string with white
528// foreground.
529func WhiteString(format string, a ...interface{}) string { return colorString(format, FgWhite, a...) }
530
531// HiBlack is a convenient helper function to print with hi-intensity black foreground. A
532// newline is appended to format by default.
533func HiBlack(format string, a ...interface{}) { colorPrint(format, FgHiBlack, a...) }
534
535// HiRed is a convenient helper function to print with hi-intensity red foreground. A
536// newline is appended to format by default.
537func HiRed(format string, a ...interface{}) { colorPrint(format, FgHiRed, a...) }
538
539// HiGreen is a convenient helper function to print with hi-intensity green foreground. A
540// newline is appended to format by default.
541func HiGreen(format string, a ...interface{}) { colorPrint(format, FgHiGreen, a...) }
542
543// HiYellow is a convenient helper function to print with hi-intensity yellow foreground.
544// A newline is appended to format by default.
545func HiYellow(format string, a ...interface{}) { colorPrint(format, FgHiYellow, a...) }
546
547// HiBlue is a convenient helper function to print with hi-intensity blue foreground. A
548// newline is appended to format by default.
549func HiBlue(format string, a ...interface{}) { colorPrint(format, FgHiBlue, a...) }
550
551// HiMagenta is a convenient helper function to print with hi-intensity magenta foreground.
552// A newline is appended to format by default.
553func HiMagenta(format string, a ...interface{}) { colorPrint(format, FgHiMagenta, a...) }
554
555// HiCyan is a convenient helper function to print with hi-intensity cyan foreground. A
556// newline is appended to format by default.
557func HiCyan(format string, a ...interface{}) { colorPrint(format, FgHiCyan, a...) }
558
559// HiWhite is a convenient helper function to print with hi-intensity white foreground. A
560// newline is appended to format by default.
561func HiWhite(format string, a ...interface{}) { colorPrint(format, FgHiWhite, a...) }
562
563// HiBlackString is a convenient helper function to return a string with hi-intensity black
564// foreground.
565func HiBlackString(format string, a ...interface{}) string {
566 return colorString(format, FgHiBlack, a...)
567}
568
569// HiRedString is a convenient helper function to return a string with hi-intensity red
570// foreground.
571func HiRedString(format string, a ...interface{}) string { return colorString(format, FgHiRed, a...) }
572
573// HiGreenString is a convenient helper function to return a string with hi-intensity green
574// foreground.
575func HiGreenString(format string, a ...interface{}) string {
576 return colorString(format, FgHiGreen, a...)
577}
578
579// HiYellowString is a convenient helper function to return a string with hi-intensity yellow
580// foreground.
581func HiYellowString(format string, a ...interface{}) string {
582 return colorString(format, FgHiYellow, a...)
583}
584
585// HiBlueString is a convenient helper function to return a string with hi-intensity blue
586// foreground.
587func HiBlueString(format string, a ...interface{}) string { return colorString(format, FgHiBlue, a...) }
588
589// HiMagentaString is a convenient helper function to return a string with hi-intensity magenta
590// foreground.
591func HiMagentaString(format string, a ...interface{}) string {
592 return colorString(format, FgHiMagenta, a...)
593}
594
595// HiCyanString is a convenient helper function to return a string with hi-intensity cyan
596// foreground.
597func HiCyanString(format string, a ...interface{}) string { return colorString(format, FgHiCyan, a...) }
598
599// HiWhiteString is a convenient helper function to return a string with hi-intensity white
600// foreground.
601func HiWhiteString(format string, a ...interface{}) string {
602 return colorString(format, FgHiWhite, a...)
603}
diff --git a/vendor/github.com/fatih/color/doc.go b/vendor/github.com/fatih/color/doc.go
new file mode 100644
index 0000000..cf1e965
--- /dev/null
+++ b/vendor/github.com/fatih/color/doc.go
@@ -0,0 +1,133 @@
1/*
2Package color is an ANSI color package to output colorized or SGR defined
3output to the standard output. The API can be used in several way, pick one
4that suits you.
5
6Use simple and default helper functions with predefined foreground colors:
7
8 color.Cyan("Prints text in cyan.")
9
10 // a newline will be appended automatically
11 color.Blue("Prints %s in blue.", "text")
12
13 // More default foreground colors..
14 color.Red("We have red")
15 color.Yellow("Yellow color too!")
16 color.Magenta("And many others ..")
17
18 // Hi-intensity colors
19 color.HiGreen("Bright green color.")
20 color.HiBlack("Bright black means gray..")
21 color.HiWhite("Shiny white color!")
22
23However there are times where custom color mixes are required. Below are some
24examples to create custom color objects and use the print functions of each
25separate color object.
26
27 // Create a new color object
28 c := color.New(color.FgCyan).Add(color.Underline)
29 c.Println("Prints cyan text with an underline.")
30
31 // Or just add them to New()
32 d := color.New(color.FgCyan, color.Bold)
33 d.Printf("This prints bold cyan %s\n", "too!.")
34
35
36 // Mix up foreground and background colors, create new mixes!
37 red := color.New(color.FgRed)
38
39 boldRed := red.Add(color.Bold)
40 boldRed.Println("This will print text in bold red.")
41
42 whiteBackground := red.Add(color.BgWhite)
43 whiteBackground.Println("Red text with White background.")
44
45 // Use your own io.Writer output
46 color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
47
48 blue := color.New(color.FgBlue)
49 blue.Fprint(myWriter, "This will print text in blue.")
50
51You can create PrintXxx functions to simplify even more:
52
53 // Create a custom print function for convenient
54 red := color.New(color.FgRed).PrintfFunc()
55 red("warning")
56 red("error: %s", err)
57
58 // Mix up multiple attributes
59 notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
60 notice("don't forget this...")
61
62You can also FprintXxx functions to pass your own io.Writer:
63
64 blue := color.New(FgBlue).FprintfFunc()
65 blue(myWriter, "important notice: %s", stars)
66
67 // Mix up with multiple attributes
68 success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
69 success(myWriter, don't forget this...")
70
71
72Or create SprintXxx functions to mix strings with other non-colorized strings:
73
74 yellow := New(FgYellow).SprintFunc()
75 red := New(FgRed).SprintFunc()
76
77 fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
78
79 info := New(FgWhite, BgGreen).SprintFunc()
80 fmt.Printf("this %s rocks!\n", info("package"))
81
82Windows support is enabled by default. All Print functions work as intended.
83However only for color.SprintXXX functions, user should use fmt.FprintXXX and
84set the output to color.Output:
85
86 fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
87
88 info := New(FgWhite, BgGreen).SprintFunc()
89 fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
90
91Using with existing code is possible. Just use the Set() method to set the
92standard output to the given parameters. That way a rewrite of an existing
93code is not required.
94
95 // Use handy standard colors.
96 color.Set(color.FgYellow)
97
98 fmt.Println("Existing text will be now in Yellow")
99 fmt.Printf("This one %s\n", "too")
100
101 color.Unset() // don't forget to unset
102
103 // You can mix up parameters
104 color.Set(color.FgMagenta, color.Bold)
105 defer color.Unset() // use it in your function
106
107 fmt.Println("All text will be now bold magenta.")
108
109There might be a case where you want to disable color output (for example to
110pipe the standard output of your app to somewhere else). `Color` has support to
111disable colors both globally and for single color definition. For example
112suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
113the color output with:
114
115 var flagNoColor = flag.Bool("no-color", false, "Disable color output")
116
117 if *flagNoColor {
118 color.NoColor = true // disables colorized output
119 }
120
121It also has support for single color definitions (local). You can
122disable/enable color output on the fly:
123
124 c := color.New(color.FgCyan)
125 c.Println("Prints cyan text")
126
127 c.DisableColor()
128 c.Println("This is printed without any color")
129
130 c.EnableColor()
131 c.Println("This prints again cyan...")
132*/
133package color