forked from zpsean/go4api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (69 loc) · 2.11 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
/*
* go4api - an api testing tool written in Go
* Created by: Ping Zhu 2018
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
package main
import (
"fmt"
"os"
"time"
"github.com/Aysnine/go4api/cmd"
"github.com/Aysnine/go4api/converter/har"
"github.com/Aysnine/go4api/converter/swagger"
"github.com/Aysnine/go4api/executor"
"github.com/Aysnine/go4api/reports"
)
func main() {
var Version = "0.71.9-2"
var Banner = `
________ ____ ___ _
/ ____ \ _______ / __ | / _ \ ______ |_|
/ / \__| / ___ \ / / | | / / \ \ | ___ \ _
| | ____ | | | | / /__| |__ / / \ \ | | \ \ | |
| | |_ _| | | | | |_____ ____| / /_____\ \ | |___/ | | |
| \____| | | |___| | | | / ________\ \ | ____/ | |
\________/ \_______/ |_| /_/ \_\ | | |_|
|_| `
fmt.Println("\nVersion: ", Version)
fmt.Println(Banner)
//get the cmd options
ch := make(chan int, 1)
fmt.Println("\n----- Start Main -----")
gStart := time.Now()
gStart_str := gStart.Format("2006-01-02 15.04.05.000000000 +0800 CST")
//
fmt.Println("Started at: " + gStart_str)
if os.Args[1] == "-run" {
executor.Dispatch(ch, gStart, gStart_str)
//
close(ch)
x := <-ch
fmt.Println("----- Finish Main -----")
// this exit code to be used for CI/CD
os.Exit(x)
} else if os.Args[1] == "-convert" {
if cmd.Opt.Harfile != "" {
har.Convert()
} else if cmd.Opt.Swaggerfile != "" {
swagger.Convert()
}
} else if os.Args[1] == "-report" {
if cmd.Opt.Logfile != "" {
reports.GenerateReportsFromLogFile(cmd.Opt.Logfile)
}
} else {
fmt.Println("Warning: no specific commnd is provided, default is to run")
executor.Dispatch(ch, gStart, gStart_str)
//
close(ch)
x := <-ch
fmt.Println("----- Finish Main -----")
// this exit code to be used for CI/CD
os.Exit(x)
}
}