-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
63 lines (49 loc) · 1.36 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
package main
import (
"flag"
"io/ioutil"
"math/rand"
"os"
"time"
"github.com/coveooss/uabot/scenariolib"
"github.com/k0kubun/pp"
)
func main() {
// Init loggers
tracePtr := flag.Bool("trace", false, "enable TRACE")
seedPtr := flag.Int64("seed", -1, "set the Randomizer seed")
flag.Parse()
traceOut := ioutil.Discard
if *tracePtr {
pp.Println("TRACE enabled")
traceOut = os.Stdout
}
scenariolib.InitLogger(traceOut, os.Stdout, os.Stdout, os.Stderr)
seed := *seedPtr
if seed == -1 {
// Seed Random based on current time
seed = int64(time.Now().Unix())
}
scenariolib.Trace.Printf("Ramdom seed: %d", seed)
rand.Seed(seed)
searchToken := os.Getenv("SEARCHTOKEN")
analyticsToken := os.Getenv("UATOKEN")
if searchToken == "" || analyticsToken == "" {
scenariolib.Error.Println("SEARCHTOKEN, UATOKEN need to be defined as env variables")
}
scenarioURL := os.Getenv("SCENARIOSURL")
if scenarioURL == "" {
scenariolib.Error.Println("SCENARIOSURL env variable needs to define a file path")
}
local := os.Getenv("LOCAL") == "true"
if local {
scenariolib.Info.Println("STARTING IN LOCAL MODE, MAKE SURE THE SCENARIOSURL IS A LOCAL PATH")
}
bot := scenariolib.NewUabot(local, scenarioURL, searchToken, analyticsToken)
quit := make(chan bool)
err := bot.Run(quit)
if err != nil {
scenariolib.Error.Println(err)
}
pp.Println("LOG >>> DONE")
}