-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (45 loc) · 1.08 KB
/
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
53
54
55
package main
import (
"fmt"
"os"
"github.com/bearki/gov/cmd"
"github.com/bearki/gov/conf"
"github.com/bearki/gov/tool"
"github.com/gookit/color"
)
const logo = `
$$$$$$\ $$$$$$\ $$\ $$\
$$ __$$\ $$ __$$\ $$ | $$ |
$$ / \__|$$ / $$ |$$ | $$ |
$$ |$$$$\ $$ | $$ |\$$\ $$ |
$$ |\_$$ |$$ | $$ | \$$\$$ /
$$ | $$ |$$ | $$ | \$$$ /
\$$$$$$ | $$$$$$ | \$ /
\______/ \______/ \_/
`
const welcome = `Welcome to Gov, an awesome Golang language version switcher.`
func main() {
// 仅在无指令或指令为help或指令不存在时打印LOGO和版本
cmdMap := cmd.GetCmdNameMap()
if len(os.Args) < 2 {
printLogoVersion()
} else if _, ok := cmdMap[os.Args[1]]; !ok {
printLogoVersion()
}
// 打印任务线
tool.L.Info(tool.StartLine)
defer tool.L.Info(tool.EndLine)
// 初始化一下配置
err := conf.Init()
if err != nil {
return
}
// 执行命令
cmd.Execute()
}
// printLogoVersion 打印LOGO和版本
func printLogoVersion() {
fmt.Println(color.Magenta.Sprint(logo))
tool.L.Warn("Gov Version %s", conf.Version)
tool.L.Trace(welcome)
}