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/fatih/color/README.md | |
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/fatih/color/README.md')
-rw-r--r-- | vendor/github.com/fatih/color/README.md | 179 |
1 files changed, 179 insertions, 0 deletions
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 | |||
5 | Color lets you use colorized outputs in terms of [ANSI Escape | ||
6 | Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It | ||
7 | has support for Windows too! The API can be used in several ways, pick one that | ||
8 | suits you. | ||
9 | |||
10 | |||
11 | ![Color](https://i.imgur.com/c1JI0lA.png) | ||
12 | |||
13 | |||
14 | ## Install | ||
15 | |||
16 | ```bash | ||
17 | go get github.com/fatih/color | ||
18 | ``` | ||
19 | |||
20 | Note that the `vendor` folder is here for stability. Remove the folder if you | ||
21 | already have the dependencies in your GOPATH. | ||
22 | |||
23 | ## Examples | ||
24 | |||
25 | ### Standard colors | ||
26 | |||
27 | ```go | ||
28 | // Print with default helper functions | ||
29 | color.Cyan("Prints text in cyan.") | ||
30 | |||
31 | // A newline will be appended automatically | ||
32 | color.Blue("Prints %s in blue.", "text") | ||
33 | |||
34 | // These are using the default foreground colors | ||
35 | color.Red("We have red") | ||
36 | color.Magenta("And many others ..") | ||
37 | |||
38 | ``` | ||
39 | |||
40 | ### Mix and reuse colors | ||
41 | |||
42 | ```go | ||
43 | // Create a new color object | ||
44 | c := color.New(color.FgCyan).Add(color.Underline) | ||
45 | c.Println("Prints cyan text with an underline.") | ||
46 | |||
47 | // Or just add them to New() | ||
48 | d := color.New(color.FgCyan, color.Bold) | ||
49 | d.Printf("This prints bold cyan %s\n", "too!.") | ||
50 | |||
51 | // Mix up foreground and background colors, create new mixes! | ||
52 | red := color.New(color.FgRed) | ||
53 | |||
54 | boldRed := red.Add(color.Bold) | ||
55 | boldRed.Println("This will print text in bold red.") | ||
56 | |||
57 | whiteBackground := red.Add(color.BgWhite) | ||
58 | whiteBackground.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 | ||
65 | color.New(color.FgBlue).Fprintln(myWriter, "blue color!") | ||
66 | |||
67 | blue := color.New(color.FgBlue) | ||
68 | blue.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 | ||
75 | red := color.New(color.FgRed).PrintfFunc() | ||
76 | red("Warning") | ||
77 | red("Error: %s", err) | ||
78 | |||
79 | // Mix up multiple attributes | ||
80 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc() | ||
81 | notice("Don't forget this...") | ||
82 | ``` | ||
83 | |||
84 | ### Custom fprint functions (FprintFunc) | ||
85 | |||
86 | ```go | ||
87 | blue := color.New(FgBlue).FprintfFunc() | ||
88 | blue(myWriter, "important notice: %s", stars) | ||
89 | |||
90 | // Mix up with multiple attributes | ||
91 | success := color.New(color.Bold, color.FgGreen).FprintlnFunc() | ||
92 | success(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: | ||
99 | yellow := color.New(color.FgYellow).SprintFunc() | ||
100 | red := color.New(color.FgRed).SprintFunc() | ||
101 | fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error")) | ||
102 | |||
103 | info := color.New(color.FgWhite, color.BgGreen).SprintFunc() | ||
104 | fmt.Printf("This %s rocks!\n", info("package")) | ||
105 | |||
106 | // Use helper functions | ||
107 | fmt.Println("This", color.RedString("warning"), "should be not neglected.") | ||
108 | fmt.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 | ||
111 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS")) | ||
112 | ``` | ||
113 | |||
114 | ### Plug into existing code | ||
115 | |||
116 | ```go | ||
117 | // Use handy standard colors | ||
118 | color.Set(color.FgYellow) | ||
119 | |||
120 | fmt.Println("Existing text will now be in yellow") | ||
121 | fmt.Printf("This one %s\n", "too") | ||
122 | |||
123 | color.Unset() // Don't forget to unset | ||
124 | |||
125 | // You can mix up parameters | ||
126 | color.Set(color.FgMagenta, color.Bold) | ||
127 | defer color.Unset() // Use it in your function | ||
128 | |||
129 | fmt.Println("All text will now be bold magenta.") | ||
130 | ``` | ||
131 | |||
132 | ### Disable/Enable color | ||
133 | |||
134 | There 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 | ||
139 | definitions. For example suppose you have a CLI app and a `--no-color` bool flag. You | ||
140 | can easily disable the color output with: | ||
141 | |||
142 | ```go | ||
143 | |||
144 | var flagNoColor = flag.Bool("no-color", false, "Disable color output") | ||
145 | |||
146 | if *flagNoColor { | ||
147 | color.NoColor = true // disables colorized output | ||
148 | } | ||
149 | ``` | ||
150 | |||
151 | It also has support for single color definitions (local). You can | ||
152 | disable/enable color output on the fly: | ||
153 | |||
154 | ```go | ||
155 | c := color.New(color.FgCyan) | ||
156 | c.Println("Prints cyan text") | ||
157 | |||
158 | c.DisableColor() | ||
159 | c.Println("This is printed without any color") | ||
160 | |||
161 | c.EnableColor() | ||
162 | c.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 | |||
178 | The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details | ||
179 | |||