aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/fatih
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-02-22 22:16:50 +0100
committerTaras Madan <tarasmadan@google.com>2023-02-24 12:47:23 +0100
commit4165372ec8fd142475a4e35fd0cf4f8042132208 (patch)
tree21cd62211b4dd80bee469054c5b65db77342333c /vendor/github.com/fatih
parent2b3ed821a493b8936c8bacfa6f8b4f1c90a00855 (diff)
dependencies: update
set go min requirements to 1.19 update dependencies update vendor
Diffstat (limited to 'vendor/github.com/fatih')
-rw-r--r--vendor/github.com/fatih/color/README.md14
-rw-r--r--vendor/github.com/fatih/color/color.go46
-rw-r--r--vendor/github.com/fatih/color/doc.go137
-rw-r--r--vendor/github.com/fatih/color/go.mod8
-rw-r--r--vendor/github.com/fatih/color/go.sum9
-rw-r--r--vendor/github.com/fatih/structtag/go.mod3
6 files changed, 96 insertions, 121 deletions
diff --git a/vendor/github.com/fatih/color/README.md b/vendor/github.com/fatih/color/README.md
index 5152bf59b..be82827ca 100644
--- a/vendor/github.com/fatih/color/README.md
+++ b/vendor/github.com/fatih/color/README.md
@@ -7,7 +7,6 @@ suits you.
![Color](https://user-images.githubusercontent.com/438920/96832689-03b3e000-13f4-11eb-9803-46f4c4de3406.jpg)
-
## Install
```bash
@@ -124,17 +123,17 @@ fmt.Println("All text will now be bold magenta.")
```
### Disable/Enable color
-
+
There might be a case where you want to explicitly disable/enable color output. the
`go-isatty` package will automatically disable color output for non-tty output streams
(for example if the output were piped directly to `less`).
The `color` package also disables color output if the [`NO_COLOR`](https://no-color.org) environment
-variable is set (regardless of its value).
+variable is set to a non-empty string.
-`Color` has support to disable/enable colors programatically both globally and
+`Color` has support to disable/enable colors programmatically both globally and
for single color definitions. For example suppose you have a CLI app and a
-`--no-color` bool flag. You can easily disable the color output with:
+`-no-color` bool flag. You can easily disable the color output with:
```go
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
@@ -167,11 +166,10 @@ To output color in GitHub Actions (or other CI systems that support ANSI colors)
* Save/Return previous values
* Evaluate fmt.Formatter interface
-
## Credits
- * [Fatih Arslan](https://github.com/fatih)
- * Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable)
+* [Fatih Arslan](https://github.com/fatih)
+* Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable)
## License
diff --git a/vendor/github.com/fatih/color/color.go b/vendor/github.com/fatih/color/color.go
index 98a60f3c8..889f9e77b 100644
--- a/vendor/github.com/fatih/color/color.go
+++ b/vendor/github.com/fatih/color/color.go
@@ -19,10 +19,10 @@ var (
// set (regardless of its value). This is a global option and affects all
// colors. For more control over each color block use the methods
// DisableColor() individually.
- NoColor = noColorExists() || os.Getenv("TERM") == "dumb" ||
+ NoColor = noColorIsSet() || os.Getenv("TERM") == "dumb" ||
(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
- // Output defines the standard output of the print functions. By default
+ // Output defines the standard output of the print functions. By default,
// os.Stdout is used.
Output = colorable.NewColorableStdout()
@@ -35,10 +35,9 @@ var (
colorsCacheMu sync.Mutex // protects colorsCache
)
-// noColorExists returns true if the environment variable NO_COLOR exists.
-func noColorExists() bool {
- _, exists := os.LookupEnv("NO_COLOR")
- return exists
+// noColorIsSet returns true if the environment variable NO_COLOR is set to a non-empty string.
+func noColorIsSet() bool {
+ return os.Getenv("NO_COLOR") != ""
}
// Color defines a custom color object which is defined by SGR parameters.
@@ -120,7 +119,7 @@ func New(value ...Attribute) *Color {
params: make([]Attribute, 0),
}
- if noColorExists() {
+ if noColorIsSet() {
c.noColor = boolPtr(true)
}
@@ -152,7 +151,7 @@ func (c *Color) Set() *Color {
return c
}
- fmt.Fprintf(Output, c.format())
+ fmt.Fprint(Output, c.format())
return c
}
@@ -164,16 +163,21 @@ func (c *Color) unset() {
Unset()
}
-func (c *Color) setWriter(w io.Writer) *Color {
+// SetWriter is used to set the SGR sequence with the given io.Writer. This is
+// a low-level function, and users should use the higher-level functions, such
+// as color.Fprint, color.Print, etc.
+func (c *Color) SetWriter(w io.Writer) *Color {
if c.isNoColorSet() {
return c
}
- fmt.Fprintf(w, c.format())
+ fmt.Fprint(w, c.format())
return c
}
-func (c *Color) unsetWriter(w io.Writer) {
+// UnsetWriter resets all escape attributes and clears the output with the give
+// io.Writer. Usually should be called after SetWriter().
+func (c *Color) UnsetWriter(w io.Writer) {
if c.isNoColorSet() {
return
}
@@ -192,20 +196,14 @@ func (c *Color) Add(value ...Attribute) *Color {
return c
}
-func (c *Color) prepend(value Attribute) {
- c.params = append(c.params, 0)
- copy(c.params[1:], c.params[0:])
- c.params[0] = value
-}
-
// Fprint formats using the default formats for its operands and writes to w.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
- c.setWriter(w)
- defer c.unsetWriter(w)
+ c.SetWriter(w)
+ defer c.UnsetWriter(w)
return fmt.Fprint(w, a...)
}
@@ -227,8 +225,8 @@ func (c *Color) Print(a ...interface{}) (n int, err error) {
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
- c.setWriter(w)
- defer c.unsetWriter(w)
+ c.SetWriter(w)
+ defer c.UnsetWriter(w)
return fmt.Fprintf(w, format, a...)
}
@@ -248,8 +246,8 @@ func (c *Color) Printf(format string, a ...interface{}) (n int, err error) {
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
- c.setWriter(w)
- defer c.unsetWriter(w)
+ c.SetWriter(w)
+ defer c.UnsetWriter(w)
return fmt.Fprintln(w, a...)
}
@@ -396,7 +394,7 @@ func (c *Color) DisableColor() {
}
// EnableColor enables the color output. Use it in conjunction with
-// DisableColor(). Otherwise this method has no side effects.
+// DisableColor(). Otherwise, this method has no side effects.
func (c *Color) EnableColor() {
c.noColor = boolPtr(false)
}
diff --git a/vendor/github.com/fatih/color/doc.go b/vendor/github.com/fatih/color/doc.go
index 04541de78..9491ad541 100644
--- a/vendor/github.com/fatih/color/doc.go
+++ b/vendor/github.com/fatih/color/doc.go
@@ -5,106 +5,105 @@ that suits you.
Use simple and default helper functions with predefined foreground colors:
- color.Cyan("Prints text in cyan.")
+ color.Cyan("Prints text in cyan.")
- // a newline will be appended automatically
- color.Blue("Prints %s in blue.", "text")
+ // a newline will be appended automatically
+ color.Blue("Prints %s in blue.", "text")
- // More default foreground colors..
- color.Red("We have red")
- color.Yellow("Yellow color too!")
- color.Magenta("And many others ..")
+ // More default foreground colors..
+ color.Red("We have red")
+ color.Yellow("Yellow color too!")
+ color.Magenta("And many others ..")
- // Hi-intensity colors
- color.HiGreen("Bright green color.")
- color.HiBlack("Bright black means gray..")
- color.HiWhite("Shiny white color!")
+ // Hi-intensity colors
+ color.HiGreen("Bright green color.")
+ color.HiBlack("Bright black means gray..")
+ color.HiWhite("Shiny white color!")
-However there are times where custom color mixes are required. Below are some
+However, there are times when custom color mixes are required. Below are some
examples to create custom color objects and use the print functions of each
separate color object.
- // Create a new color object
- c := color.New(color.FgCyan).Add(color.Underline)
- c.Println("Prints cyan text with an underline.")
+ // Create a new color object
+ c := color.New(color.FgCyan).Add(color.Underline)
+ c.Println("Prints cyan text with an underline.")
- // Or just add them to New()
- d := color.New(color.FgCyan, color.Bold)
- d.Printf("This prints bold cyan %s\n", "too!.")
+ // Or just add them to New()
+ d := color.New(color.FgCyan, color.Bold)
+ d.Printf("This prints bold cyan %s\n", "too!.")
- // Mix up foreground and background colors, create new mixes!
- red := color.New(color.FgRed)
+ // Mix up foreground and background colors, create new mixes!
+ red := color.New(color.FgRed)
- boldRed := red.Add(color.Bold)
- boldRed.Println("This will print text in bold red.")
+ boldRed := red.Add(color.Bold)
+ boldRed.Println("This will print text in bold red.")
- whiteBackground := red.Add(color.BgWhite)
- whiteBackground.Println("Red text with White background.")
+ whiteBackground := red.Add(color.BgWhite)
+ whiteBackground.Println("Red text with White background.")
- // Use your own io.Writer output
- color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
+ // Use your own io.Writer output
+ color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
- blue := color.New(color.FgBlue)
- blue.Fprint(myWriter, "This will print text in blue.")
+ blue := color.New(color.FgBlue)
+ blue.Fprint(myWriter, "This will print text in blue.")
You can create PrintXxx functions to simplify even more:
- // Create a custom print function for convenient
- red := color.New(color.FgRed).PrintfFunc()
- red("warning")
- red("error: %s", err)
+ // Create a custom print function for convenient
+ red := color.New(color.FgRed).PrintfFunc()
+ red("warning")
+ red("error: %s", err)
- // Mix up multiple attributes
- notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
- notice("don't forget this...")
+ // Mix up multiple attributes
+ notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
+ notice("don't forget this...")
You can also FprintXxx functions to pass your own io.Writer:
- blue := color.New(FgBlue).FprintfFunc()
- blue(myWriter, "important notice: %s", stars)
-
- // Mix up with multiple attributes
- success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
- success(myWriter, don't forget this...")
+ blue := color.New(FgBlue).FprintfFunc()
+ blue(myWriter, "important notice: %s", stars)
+ // Mix up with multiple attributes
+ success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
+ success(myWriter, don't forget this...")
Or create SprintXxx functions to mix strings with other non-colorized strings:
- yellow := New(FgYellow).SprintFunc()
- red := New(FgRed).SprintFunc()
+ yellow := New(FgYellow).SprintFunc()
+ red := New(FgRed).SprintFunc()
- fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
+ fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
- info := New(FgWhite, BgGreen).SprintFunc()
- fmt.Printf("this %s rocks!\n", info("package"))
+ info := New(FgWhite, BgGreen).SprintFunc()
+ fmt.Printf("this %s rocks!\n", info("package"))
Windows support is enabled by default. All Print functions work as intended.
-However only for color.SprintXXX functions, user should use fmt.FprintXXX and
+However, only for color.SprintXXX functions, user should use fmt.FprintXXX and
set the output to color.Output:
- fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
+ fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
- info := New(FgWhite, BgGreen).SprintFunc()
- fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
+ info := New(FgWhite, BgGreen).SprintFunc()
+ fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
Using with existing code is possible. Just use the Set() method to set the
standard output to the given parameters. That way a rewrite of an existing
code is not required.
- // Use handy standard colors.
- color.Set(color.FgYellow)
+ // Use handy standard colors.
+ color.Set(color.FgYellow)
- fmt.Println("Existing text will be now in Yellow")
- fmt.Printf("This one %s\n", "too")
+ fmt.Println("Existing text will be now in Yellow")
+ fmt.Printf("This one %s\n", "too")
- color.Unset() // don't forget to unset
+ color.Unset() // don't forget to unset
- // You can mix up parameters
- color.Set(color.FgMagenta, color.Bold)
- defer color.Unset() // use it in your function
+ // You can mix up parameters
+ color.Set(color.FgMagenta, color.Bold)
+ defer color.Unset() // use it in your function
- fmt.Println("All text will be now bold magenta.")
+ fmt.Println("All text will be now bold magenta.")
There might be a case where you want to disable color output (for example to
pipe the standard output of your app to somewhere else). `Color` has support to
@@ -112,24 +111,24 @@ disable colors both globally and for single color definition. For example
suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
the color output with:
- var flagNoColor = flag.Bool("no-color", false, "Disable color output")
+ var flagNoColor = flag.Bool("no-color", false, "Disable color output")
- if *flagNoColor {
- color.NoColor = true // disables colorized output
- }
+ if *flagNoColor {
+ color.NoColor = true // disables colorized output
+ }
You can also disable the color by setting the NO_COLOR environment variable to any value.
It also has support for single color definitions (local). You can
disable/enable color output on the fly:
- c := color.New(color.FgCyan)
- c.Println("Prints cyan text")
+ c := color.New(color.FgCyan)
+ c.Println("Prints cyan text")
- c.DisableColor()
- c.Println("This is printed without any color")
+ c.DisableColor()
+ c.Println("This is printed without any color")
- c.EnableColor()
- c.Println("This prints again cyan...")
+ c.EnableColor()
+ c.Println("This prints again cyan...")
*/
package color
diff --git a/vendor/github.com/fatih/color/go.mod b/vendor/github.com/fatih/color/go.mod
deleted file mode 100644
index c9b3cd59a..000000000
--- a/vendor/github.com/fatih/color/go.mod
+++ /dev/null
@@ -1,8 +0,0 @@
-module github.com/fatih/color
-
-go 1.13
-
-require (
- github.com/mattn/go-colorable v0.1.9
- github.com/mattn/go-isatty v0.0.14
-)
diff --git a/vendor/github.com/fatih/color/go.sum b/vendor/github.com/fatih/color/go.sum
deleted file mode 100644
index cbbcfb644..000000000
--- a/vendor/github.com/fatih/color/go.sum
+++ /dev/null
@@ -1,9 +0,0 @@
-github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
-github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
-github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
-github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
-github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/vendor/github.com/fatih/structtag/go.mod b/vendor/github.com/fatih/structtag/go.mod
deleted file mode 100644
index 660d6a1f1..000000000
--- a/vendor/github.com/fatih/structtag/go.mod
+++ /dev/null
@@ -1,3 +0,0 @@
-module github.com/fatih/structtag
-
-go 1.12