-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 938 Bytes
/
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
// Launches a small Blood on the Clocktower discord mover bot.
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"github.com/zku/botc-discord-mover/mover"
)
var configPath = flag.String("config", ".config.json", "Path to config file (json).")
func main() {
flag.Parse()
cfg := &mover.Config{}
if *configPath != "" {
contents, err := ioutil.ReadFile(*configPath)
if err != nil {
log.Fatalf("Cannot load config file %q: %v", *configPath, err)
}
if err := json.Unmarshal(contents, cfg); err != nil {
log.Fatalf("Cannot parse config: %v", err)
}
} else {
var err error
cfg, err = mover.ConfigFromEnv()
if err != nil {
log.Fatalf("Cannot load config from environment variables: %v", err)
}
}
if err := cfg.Validate(); err != nil {
log.Fatalf("Incomplete config: %v", err)
}
m := mover.New(cfg)
if err := m.RunForever(); err != nil {
log.Fatalf("Mover terminated: %v", err)
}
}