-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.go
52 lines (43 loc) · 896 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
52
package main
import (
"flag"
"fmt"
)
const (
// IconGood is success symbol
IconGood = "✔"
// IconBad is failed symbol
IconBad = "✗"
)
var version = "v0.1.0"
func main() {
versionFlag := flag.Bool("v", false, "display version info")
flag.Parse()
if *versionFlag {
fmt.Println(green(logo))
fmt.Printf(source, version)
return
}
fmt.Println(green(logo))
games, err := getGames()
if err != nil {
fmt.Printf("%s %s\n", red(IconBad), "获取比赛列表失败")
return
}
if len(games) == 0 {
fmt.Printf("%s %s\n", green(IconGood), "暂无比赛数据")
return
}
i, err := newSelect(games)
if err != nil {
fmt.Printf("%s %s\n", red(IconBad), "选择比赛错误")
return
}
newUI(games[i])
}
func red(str string) string {
return fmt.Sprintf("\x1b[0;31m%s\x1b[0m", str)
}
func green(str string) string {
return fmt.Sprintf("\x1b[0;32m%s\x1b[0m", str)
}