-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
65 lines (56 loc) · 1.35 KB
/
config.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"os"
"strings"
cl "bitbucket.org/ai69/so-colorful/colorlogo"
"github.com/1set/gut/yos"
"github.com/1set/gut/ystring"
)
var (
AppName string
CIBuildNum string
BuildDate string
BuildHost string
GoVersion string
GitBranch string
GitCommit string
GitSummary string
)
var (
logoArt = `
██████╗██╗ ██╗
██╔════╝██║ ██║
██║ ██║ ██║
██║ ██║ ██║
╚██████╗███████╗██║
╚═════╝╚══════╝╚═╝
`
logoArtColor = cl.CherryBlossomsByColumn(logoArt)
)
func displayBuildInfo() {
if ystring.IsBlank(BuildDate) {
return
}
var sb strings.Builder
flag := "➣ "
if yos.IsOnWindows() {
flag = "> "
} else {
sb.WriteString(logoArtColor)
}
addNonBlankField := func(name, value string) {
if ystring.IsNotBlank(value) {
fmt.Fprintln(&sb, flag+name+":", value)
}
}
addNonBlankField("Build Num ", CIBuildNum)
addNonBlankField("Build Date", BuildDate)
addNonBlankField("Build Host", BuildHost)
addNonBlankField("Go Version", GoVersion)
addNonBlankField("Git Branch", GitBranch)
addNonBlankField("Git Commit", GitCommit)
addNonBlankField("GitSummary", GitSummary)
rs := sb.String() + ystring.NewLine
os.Stderr.WriteString(rs)
}