-
Notifications
You must be signed in to change notification settings - Fork 66
/
main.go
88 lines (69 loc) · 1.75 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"flag"
"github.com/aaronchen2k/deeptest/cmd/command/action"
commandConfig "github.com/aaronchen2k/deeptest/internal/command/config"
zapLog "github.com/aaronchen2k/deeptest/internal/pkg/log"
_consts "github.com/aaronchen2k/deeptest/pkg/consts"
"github.com/fatih/color"
"os"
"os/signal"
"syscall"
)
var (
AppVersion string
BuildTime string
GoVersion string
GitHash string
scenarioId int
planId int
envId int
server string
token string
language string
flagSet *flag.FlagSet
)
func main() {
channel := make(chan os.Signal)
signal.Notify(channel, os.Interrupt, syscall.SIGTERM)
go func() {
<-channel
cleanup()
os.Exit(0)
}()
flagSet = flag.NewFlagSet("deeptest", flag.ContinueOnError)
flagSet.IntVar(&scenarioId, "s", 0, "")
flagSet.IntVar(&scenarioId, "scenario", 0, "")
flagSet.IntVar(&planId, "p", 0, "")
flagSet.IntVar(&planId, "plan", 0, "")
flagSet.IntVar(&envId, "e", 0, "")
flagSet.IntVar(&envId, "env", 0, "")
flagSet.StringVar(&server, "S", "", "")
flagSet.StringVar(&server, "server", "", "")
flagSet.StringVar(&token, "t", "", "")
flagSet.StringVar(&token, "token", "", "")
flagSet.BoolVar(&_consts.Verbose, "verbose", false, "")
flagSet.Parse(os.Args[1:])
switch os.Args[1] {
case "help", "-h", "-help", "--help":
action.PrintUsage(language)
default:
if (scenarioId == 0 && planId == 0) || envId == 0 || server == "" || token == "" {
action.PrintUsage(language)
return
} else {
run(scenarioId, planId, envId, server, token)
}
}
}
func run(scenarioId, planId, envId int, server, token string) {
action.Run(scenarioId, planId, envId, server, token)
}
func init() {
cleanup()
commandConfig.InitConfig()
zapLog.Init()
}
func cleanup() {
color.Unset()
}