-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
47 lines (35 loc) · 1.16 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
package main
import (
"fmt"
"os"
analyser "github.com/quancore/demoanalyzer-go/analyser"
utils "github.com/quancore/demoanalyzer-go/utils"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
func init() {
utils.ReadConfFile()
pflag.String("demofilepath", "", "The path of demofile")
pflag.String("outpath", "", "The path of result text file")
pflag.String("logfilepath", "log.txt", "The path of result text file")
pflag.Bool("checkanalyzer", false, "Flag whether test analyser result when finished")
pflag.Parse()
viper.BindPFlags(pflag.CommandLine)
if _, err := os.Stat(viper.GetString("demofilepath")); err != nil {
panic(fmt.Sprintf("Failed to read test demo %q", viper.GetString("demofilepath")))
}
}
func main() {
// defer utils.RecoverPanic()
demoFilePath := viper.GetString("demofilepath")
outPath := viper.GetString("outpath")
logpath := viper.GetString("logfilepath")
isMethodName := viper.GetBool("log.is_method_name")
f, err := os.Open(demoFilePath)
defer f.Close()
utils.CheckError(err)
// initilize analyser
analyser := analyser.NewAnalyser(f, logpath, outPath, isMethodName, true)
// finally parse demofile
analyser.Analyze()
}