-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
87 lines (70 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
package main
import (
"flag"
"fmt"
"os"
)
type argStruct struct {
// Url or file name of the OpenAPI v.3 specification file
oasFile *string
auth *bool
localhost *bool
onlyGet *bool
requestParam *int
validate *bool
singleThread *bool
}
func main() {
oasFile := flag.String(
"oas", "", "Required, file name of the OpenAPI 3.0 specification file")
auth := flag.Bool("auth", false,
"Use authentication, i.e. authentication token is used to authorize requests")
localhost := flag.Bool("localhost", false,
"Not implemented. Use when testing API that runs on your local machine")
onlyGet := flag.Bool("only-get", false, "Not implemented. Test only GET requests")
requestParam := flag.Int("req-param", 13,
"Integer used in requests that contain parameters")
validate := flag.Bool("validate", false, "Validate file given to \"oas\" argument")
singleThread := flag.Bool("single-thread", false,
"Use single thread for HTTP requests.")
help := flag.Bool("help", false, "Show help")
flag.Parse()
if *help {
flag.PrintDefaults()
os.Exit(0)
}
//*oasFile = "specs/api.github.com.json"
if *oasFile == "" {
fmt.Println("\"oas\" argument is required")
flag.PrintDefaults()
os.Exit(1)
}
args := argStruct{
oasFile,
auth,
localhost,
onlyGet,
requestParam,
validate,
singleThread,
}
printArguments(args)
//printToken()
run(args)
}
func printArguments(args argStruct) {
fmt.Println("oas:", *args.oasFile)
if *args.auth {
fmt.Println("auth:", *args.auth)
}
if *args.localhost {
fmt.Println("localhost:", *args.localhost)
}
if *args.onlyGet {
fmt.Println("only-get:", *args.onlyGet)
}
fmt.Println("req-param:", *args.requestParam)
if *args.validate {
fmt.Println("validate:", *args.validate)
}
}