-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jubilee.go
executable file
·111 lines (88 loc) · 1.96 KB
/
Jubilee.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import (
"Jubilee/CommandInterpreter"
"Jubilee/Driver"
"bufio"
"fmt"
"os"
"strings"
)
func main() {
var options string
var path string
if len(os.Args) < 2 {
fmt.Println("Not enough Arguments!")
return
} else if len(os.Args) == 2 {
OneArg()
return
} else if len(os.Args) == 3 {
options, path = TwoArgs()
} else {
fmt.Println("Too many Args!")
return
}
Begin(options, path)
}
func pause() {
reader := bufio.NewReader(os.Stdin)
fmt.Println("---------------------")
for {
fmt.Print("-> ")
text, _ := reader.ReadString('\n')
// convert CRLF to LF
text = strings.Replace(text, "\n", "", -1)
if strings.Compare("continue", text) == 0 {
return
}
}
}
func OneArg() {
if strings.HasPrefix(os.Args[1], "-") {
if strings.Compare(os.Args[1], "-h") == 0 {
Help()
} else {
fmt.Println("you need to provide a path as well")
}
} else {
seleniumPath, driverPath, port, browser, err := CommandInterpreter.LoadFile(os.Args[1])
if err != nil {
panic(err)
}
Driver.Start(seleniumPath, driverPath, port, browser)
CommandInterpreter.RunCommands()
}
}
func TwoArgs() (string,string) {
var options string
if strings.HasPrefix(os.Args[1], "-") {
options = os.Args[1]
} else {
options = "-"
}
path := os.Args[2]
return options, path
}
func Begin(options string, path string) {
if strings.Contains(options, "d") {
//put folder code here
} else {
StartFile(options, path)
}
}
func StartFile(options string, path string) {
seleniumPath, driverPath, port, browser, err := CommandInterpreter.LoadFile(path)
if err != nil {
panic(err)
}
Driver.Start(seleniumPath, driverPath, port, browser)
CommandInterpreter.RunCommands()
if strings.Contains(options, "p") {
pause()
}
}
func Help() {
fmt.Println("Format: [options] [path]")
fmt.Println("d: pass a directory path, and run all of the scripts in that directory")
fmt.Println("p: pause after running the script, instead of closing the browser")
}