-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
72 lines (57 loc) · 1.17 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
package main
import (
"checkup/Godeps/_workspace/src/github.com/codegangsta/cli"
"checkup/parsers"
"checkup/steps"
"fmt"
"os"
"regexp"
)
func main() {
cli.AppHelpTemplate = AppHelpTemplate
app := cli.NewApp()
app.Name = "checkup"
app.Version = Version
app.HideHelp = true
app.Usage = "E2E Testing Application"
app.Author = "aqafiam"
app.Before = doBefore
app.Action = doMain
app.Flags = []cli.Flag{
cli.HelpFlag,
remoteFlag,
}
app.Run(os.Args)
}
func doBefore(c *cli.Context) error {
args := c.Args()
if len(args) == 0 {
cli.ShowAppHelp(c)
os.Exit(1)
}
for _, arg := range args {
ok, _ := regexp.MatchString(`\.ya?ml$`, arg)
if !ok {
fmt.Println(arg + " is not yaml file.")
os.Exit(2)
}
}
return nil
}
func doMain(c *cli.Context) {
steps.Datas = parsers.ParseYaml(c.Args())
for _, data := range steps.Datas {
steps.Init(c.String("remote"), data)
}
}
var remoteFlag = cli.StringFlag{
Name: "remote, r",
Value: "http://localhost:4444/wd/hub",
Usage: "Remote WebDriver Server's URL",
}
const Version string = "0.1.0"
const AppHelpTemplate string = `Usage: {{.Name}} [options] [testcase.yml...]
Options:
{{range .Flags}} {{.}}
{{end}}
`