/
banner.go
55 lines (45 loc) · 1.41 KB
/
banner.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
package basesvc
import (
_ "embed"
"fmt"
"os"
"text/template"
"github.com/fatih/color"
"go.autokitteh.dev/autokitteh/internal/kittehs"
"go.autokitteh.dev/autokitteh/internal/version"
)
//go:embed banner.txt
var banner string
var bannerTemplate = template.Must(template.New("banner").Parse(banner))
func printBanner(opts RunOptions, addr, temporalFrontendAddr, temporalUIAddr string) {
fieldColor := color.New(color.FgBlue).Add(color.Bold).SprintFunc()
eyeColor := color.New(color.FgGreen).Add(color.Bold).SprintFunc()
var mode string
if opts.Mode != "" {
mode = "Mode: " + fieldColor(opts.Mode) + " "
}
if temporalFrontendAddr != "" {
temporalFrontendAddr = "Temporal: " + fieldColor(temporalFrontendAddr) + " "
}
if temporalUIAddr != "" {
temporalUIAddr = "Temporal UI: " + fieldColor(temporalUIAddr) + " "
}
kittehs.Must0(bannerTemplate.Execute(os.Stderr, struct {
Version string
PID string
Addr string
Eye string
UIAddr string
Mode string
Temporal, TemporalUI string
}{
Version: fieldColor(version.Version),
PID: fieldColor(fmt.Sprintf("%d", os.Getpid())),
Addr: fieldColor(addr),
UIAddr: fieldColor(fmt.Sprintf("http://%s", addr)),
Eye: eyeColor("▀"),
Mode: mode,
Temporal: temporalFrontendAddr,
TemporalUI: temporalUIAddr,
}))
}