diff --git a/go.mod b/go.mod index 2939233..50b5f32 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.26.9 require ( github.com/google/go-github/v89 v89.0.0 - github.com/gookit/color v1.6.1 + github.com/gookit/color v1.6.3 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c github.com/sirupsen/logrus v1.10.2 github.com/spf13/cobra v1.10.2 diff --git a/go.sum b/go.sum index 529fa71..21342c5 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfh github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU= github.com/gookit/assert v0.1.1 h1:lh3GcawXe/p+cU7ESTZ5Ui3Sm/x8JWpIis4/1aF0mY0= github.com/gookit/assert v0.1.1/go.mod h1:jS5bmIVQZTIwk42uXl4lyj4iaaxx32tqH16CFj0VX2E= -github.com/gookit/color v1.6.1 h1:KoTnDxJPRgrL0SoX0f8rCFg2zI0t4E3GZZBMo2nN8LU= -github.com/gookit/color v1.6.1/go.mod h1:9ACFc7/1IpHGBW8RwuDm/0YEnhg3dwwXpoMsmtyHfjs= +github.com/gookit/color v1.6.3 h1:m6E49x+KftGaspcLtPLMsyci2ARhWIUW0PUV1owMlhs= +github.com/gookit/color v1.6.3/go.mod h1:9ACFc7/1IpHGBW8RwuDm/0YEnhg3dwwXpoMsmtyHfjs= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= diff --git a/vendor/github.com/gookit/color/color.go b/vendor/github.com/gookit/color/color.go index a51bde0..a949db4 100644 --- a/vendor/github.com/gookit/color/color.go +++ b/vendor/github.com/gookit/color/color.go @@ -120,22 +120,37 @@ func ResetOptions() { output = os.Stdout } +var oldLevelVal Level + // ForceSetColorLevel force open color render func ForceSetColorLevel(level Level) Level { - oldLevelVal := colorLevel + oldLevelVal = colorLevel colorLevel = level return oldLevelVal } -// ForceColor force open color render +// ForceColor force open color render. alias of ForceOpenColor +// +// Use for testing: +// +// color.ForceColor() +// defer color.RevertColorLevel() func ForceColor() Level { return ForceOpenColor() } // ForceOpenColor force open color render +// +// Use for testing: +// +// color.ForceColor() +// defer color.RevertColorLevel() func ForceOpenColor() Level { // TODO should set level to ? return ForceSetColorLevel(LevelRgb) } +// RevertColorLevel value +func RevertColorLevel() { colorLevel = oldLevelVal } + // EnableDebug enable debug mode func EnableDebug() { debugMode = true } diff --git a/vendor/github.com/gookit/color/convert.go b/vendor/github.com/gookit/color/convert.go index 21344e7..c957965 100644 --- a/vendor/github.com/gookit/color/convert.go +++ b/vendor/github.com/gookit/color/convert.go @@ -483,7 +483,9 @@ func RgbToHex(rgb []int) string { hexNodes := make([]string, 0, len(rgb)) for _, v := range rgb { - hexNodes = append(hexNodes, strconv.FormatInt(int64(v), 16)) + // Channels below 0x10 must keep two digits, or the fixed-width format and + // the round-trip with HexToRgb both break. + hexNodes = append(hexNodes, fmt.Sprintf("%02x", v)) } return strings.Join(hexNodes, "") } @@ -610,6 +612,14 @@ func RgbTo256(r, g, b uint8) uint8 { // C256ToRgb convert an 256 color code to RGB numbers func C256ToRgb(val uint8) (rgb []uint8) { + if val >= 232 { + level := uint8(8 + 10*int(val-232)) + return []uint8{level, level, level} + } + if val >= 16 { + index := val - 16 + return []uint8{incs[index/36], incs[index/6%6], incs[index%6]} + } hex := c256ToHexMap[val] // convert to rgb code rgbInts := Hex2rgb(hex) diff --git a/vendor/modules.txt b/vendor/modules.txt index f98b5b3..3d96e4c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -12,7 +12,7 @@ github.com/google/go-github/v89/github # github.com/google/go-querystring v1.2.0 ## explicit; go 1.13 github.com/google/go-querystring/query -# github.com/gookit/color v1.6.1 +# github.com/gookit/color v1.6.3 ## explicit; go 1.18 github.com/gookit/color # github.com/inconshreveable/mousetrap v1.1.0