Skip to content

Commit e8634ca

Browse files
author
nate smith
committed
use mgutz/ansi in utils
1 parent a66aaaf commit e8634ca

File tree

3 files changed

+19
-38
lines changed

3 files changed

+19
-38
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module github.com/github/gh-cli
33
go 1.13
44

55
require (
6-
github.com/gookit/color v1.2.0
76
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
87
github.com/mattn/go-colorable v0.1.2
98
github.com/mattn/go-isatty v0.0.9
9+
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
1010
github.com/mitchellh/go-homedir v1.1.0
1111
github.com/spf13/cobra v0.0.5
1212
gopkg.in/yaml.v3 v3.0.0-20191010095647-fc94e3f71652

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
99
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1010
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1111
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
12-
github.com/gookit/color v1.2.0 h1:lHA77Kuyi5JpBnA9ESvwkY+nanLjRZ0mHbWQXRYk2Lk=
13-
github.com/gookit/color v1.2.0/go.mod h1:AhIE+pS6D4Ql0SQWbBeXPHw7gY0/sjHoA4s/n1KB7xg=
1412
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
1513
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
1614
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
@@ -22,6 +20,8 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc
2220
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
2321
github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg=
2422
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
23+
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
24+
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
2525
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
2626
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
2727
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=

utils/color.go

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,24 @@
11
package utils
22

3-
import "github.com/gookit/color"
3+
import "github.com/mgutz/ansi"
44

5-
func Black(a ...interface{}) string {
6-
return color.Black.Render(a...)
7-
}
8-
9-
func White(a ...interface{}) string {
10-
return color.White.Render(a...)
11-
}
12-
13-
func Gray(a ...interface{}) string {
14-
return color.Gray.Render(a...)
15-
}
16-
17-
func Red(a ...interface{}) string {
18-
return color.Red.Render(a...)
19-
}
5+
var Black = ansi.ColorFunc("black")
6+
var White = ansi.ColorFunc("white")
207

21-
func Green(a ...interface{}) string {
22-
return color.Green.Render(a...)
8+
func Gray(arg string) string {
9+
return ansi.Color(ansi.LightBlack+arg, "")
2310
}
2411

25-
func Yellow(a ...interface{}) string {
26-
return color.Yellow.Render(a...)
27-
}
28-
29-
func Blue(a ...interface{}) string {
30-
return color.Blue.Render(a...)
31-
}
32-
33-
func Magenta(a ...interface{}) string {
34-
return color.Magenta.Render(a...)
35-
}
36-
37-
func Cyan(a ...interface{}) string {
38-
return color.Cyan.Render(a...)
39-
}
12+
var Red = ansi.ColorFunc("red")
13+
var Green = ansi.ColorFunc("green")
14+
var Yellow = ansi.ColorFunc("yellow")
15+
var Blue = ansi.ColorFunc("blue")
16+
var Magenta = ansi.ColorFunc("magenta")
17+
var Cyan = ansi.ColorFunc("cyan")
4018

41-
func Bold(a ...interface{}) string {
42-
return color.Bold.Render(a...)
19+
func Bold(arg string) string {
20+
// This is really annoying. If you just define Bold as ColorFunc("+b") it will properly bold but
21+
// will not use the default color, resulting in black and probably unreadable text. This forces
22+
// the default color before bolding.
23+
return ansi.Color(ansi.DefaultFG+arg, "+b")
4324
}

0 commit comments

Comments
 (0)