forked from txthinking/frank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
59 lines (54 loc) · 1.04 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
package main
import (
"log"
_ "net/http/pprof"
"os"
"github.com/fatih/color"
"github.com/urfave/cli"
)
var markdown bool
func main() {
app := cli.NewApp()
app.Name = "Frank"
app.Version = "20171221"
app.Usage = "Command line REST API automated testing tool"
app.Authors = []*cli.Author{
{
Name: "Cloud",
Email: "[email protected]",
},
}
app.Flags = []cli.Flag{
&cli.BoolFlag{
Name: "markdown, m",
Usage: "Print markdown document",
Destination: &markdown,
},
&cli.Int64Flag{
Name: "delay, d",
Usage: "Delay per request, (millisecond)",
Value: 0,
},
&cli.StringFlag{
Name: "case, c",
Usage: "Path of case file",
Value: "case.frank",
},
}
app.Action = func(c *cli.Context) error {
if err := runCase(c.String("case"), c.Int64("delay")); err != nil {
color.Red(err.Error())
}
return nil
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
func runCase(f string, d int64) error {
c, err := NewCase(f, d)
if err != nil {
return err
}
return c.Run()
}