-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflight-go.go
46 lines (43 loc) · 989 Bytes
/
flight-go.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
package main
import (
"os"
"time"
)
const (
serviceName string = "Flight-Go"
currentServiceVersion string = "v0.1.0"
logMaxAge = time.Hour * 24
logRotationTime = time.Hour * 24
logPath string = ""
logFileName string = "Flight-Go.log"
)
func main() {
// 初始化日志
logger = NewLogger(logMaxAge, logRotationTime, logPath, logFileName)
// 命令行初始化
commandLineInit()
commands := flightCommands
args := os.Args
if len(args) > 1 {
for _, cmd := range commands {
if cmd.Run != nil && cmd.Name() == args[1] {
err := cmd.Flag.Parse(args[2:])
if err != nil {
os.Exit(1)
}
args = cmd.Flag.Args()
if len(args) > 0 {
// 初始化数据
initCityNameCodeData()
os.Exit(cmd.Run(args))
}
logger.Errorf("[Flight-Go]命令参数错误!")
break
}
}
commandUsage()
} else {
logger.Errorf("[Flight-Go]命令参数错误!")
commandUsage()
}
}