Switch to released tag v1.0.0 for github.com/daviddengcn/go-colortext

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas
2022-06-10 15:58:34 -04:00
parent 7e66aa3cfb
commit 8cf2ef5558
7 changed files with 38 additions and 18 deletions

View File

@@ -5,6 +5,11 @@ Under windows platform, the Console API is used. Under other systems, ANSI text
*/
package ct
import (
"io"
"os"
)
// Color is the type of color to be set.
type Color int
@@ -21,6 +26,9 @@ const (
White
)
// Writer is the io.Writer where ANSI escape codes will be written to
var Writer io.Writer = os.Stdout
// ResetColor resets the foreground and background to original colors
func ResetColor() {
resetColor()

View File

@@ -16,7 +16,7 @@ func resetColor() {
if isDumbTerm() {
return
}
fmt.Print("\x1b[0m")
fmt.Fprint(Writer, "\x1b[0m")
}
func ansiText(fg Color, fgBright bool, bg Color, bgBright bool) string {
@@ -32,6 +32,9 @@ func ansiText(fg Color, fgBright bool, bg Color, bgBright bool) string {
}
if bg != None {
s = strconv.AppendUint(append(s, ";"...), 40+(uint64)(bg-Black), 10)
if bgBright {
s = append(s, ";1"...)
}
}
s = append(s, "m"...)
return string(s)
@@ -44,5 +47,5 @@ func changeColor(fg Color, fgBright bool, bg Color, bgBright bool) {
if fg == None && bg == None {
return
}
fmt.Print(ansiText(fg, fgBright, bg, bgBright))
fmt.Fprint(Writer, ansiText(fg, fgBright, bg, bgBright))
}

10
vendor/modules.txt vendored
View File

@@ -242,8 +242,8 @@ github.com/cyphar/filepath-securejoin
# github.com/davecgh/go-spew v1.1.1 => github.com/davecgh/go-spew v1.1.1
## explicit
github.com/davecgh/go-spew/spew
# github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd => github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd
## explicit
# github.com/daviddengcn/go-colortext v1.0.0 => github.com/daviddengcn/go-colortext v1.0.0
## explicit; go 1.14
github.com/daviddengcn/go-colortext
# github.com/docker/distribution v2.8.1+incompatible => github.com/docker/distribution v2.8.1+incompatible
## explicit
@@ -2618,7 +2618,7 @@ sigs.k8s.io/yaml
# github.com/creack/pty => github.com/creack/pty v1.1.11
# github.com/cyphar/filepath-securejoin => github.com/cyphar/filepath-securejoin v0.2.3
# github.com/davecgh/go-spew => github.com/davecgh/go-spew v1.1.1
# github.com/daviddengcn/go-colortext => github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd
# github.com/daviddengcn/go-colortext => github.com/daviddengcn/go-colortext v1.0.0
# github.com/dnaeon/go-vcr => github.com/dnaeon/go-vcr v1.0.1
# github.com/docker/distribution => github.com/docker/distribution v2.8.1+incompatible
# github.com/docker/docker => github.com/docker/docker v20.10.12+incompatible
@@ -2664,7 +2664,9 @@ sigs.k8s.io/yaml
# github.com/golang/groupcache => github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
# github.com/golang/mock => github.com/golang/mock v1.6.0
# github.com/golang/protobuf => github.com/golang/protobuf v1.5.2
# github.com/golangplus/testing => github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e
# github.com/golangplus/bytes => github.com/golangplus/bytes v1.0.0
# github.com/golangplus/fmt => github.com/golangplus/fmt v1.0.0
# github.com/golangplus/testing => github.com/golangplus/testing v1.0.0
# github.com/google/btree => github.com/google/btree v1.0.1
# github.com/google/cadvisor => github.com/google/cadvisor v0.44.1
# github.com/google/cel-go => github.com/google/cel-go v0.11.2