-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
51 lines (43 loc) · 744 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package strcolor
import (
"fmt"
"os"
"github.com/fatih/color"
)
type ColorCode int
const (
Black ColorCode = iota + 30
Red
Green
Yellow
Blue
Magenta
Cyan
White
BrightBlack ColorCode = iota + 82
BrightRed
BrightGreen
BrightYellow
BrightBlue
BrightMagenta
BrightCyan
BrightWhite
)
func GetColorString(colorCode ColorCode, words ...string) string {
agentID := os.Getenv("AGENT_ID")
isPipeline := false
if len(agentID) != 0 {
isPipeline = true
}
var builder string
for _, m := range words {
if len(builder) > 0 {
builder += " "
}
builder += m
}
if isPipeline {
return fmt.Sprintf("\033[%vm%v\033[0m", fmt.Sprint(colorCode), builder)
}
return color.New(color.Attribute(colorCode)).Sprint(builder)
}