-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
88 lines (78 loc) · 1.8 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"os"
"github.com/docopt/docopt-go"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)
var version = "not set"
var logLevel = "not set"
var saveNotRecognized = "not set"
var collectSamples = "not set"
var saveImages = "not set"
func init() {
log.SetFormatter(&log.TextFormatter{
ForceColors: true,
DisableQuote: true,
DisableLevelTruncation: true,
PadLevelText: true,
FullTimestamp: true,
})
log.Infof("new-world-map-coordinates-sse-%s", version)
ll, err := logrus.ParseLevel(logLevel)
if err != nil {
ll = logrus.InfoLevel
}
log.SetLevel(ll)
log.Debug("running in debug log level")
}
var usage = `New World Map Coordinates SSE: A simple service that exposes New World's player's position as SSE stream.
Usage:
map-coordinates-sse.exe --version
map-coordinates-sse.exe
map-coordinates-sse.exe [--bind=<a>]
map-coordinates-sse.exe [--display=<n>]
Options:
-h --help Show this screen.
--version Show version.
--display=<n> Display to use [default: 0].
--bind=<a> address and port to serve on [default: :5000].
`
func gatherConfig() Config {
opts, err := docopt.ParseArgs(usage, os.Args[1:], version)
if err != nil {
panic(err)
}
addr, err := opts.String("--bind")
if err != nil {
panic(err)
}
display, err := opts.Int("--display")
if err != nil {
panic(err)
}
log.Debugf("Using display=%v", display)
sNR := false
if saveNotRecognized == "save" {
sNR = true
}
cS := false
if collectSamples == "true" {
cS = true
}
sI := false
if saveImages == "true" {
sI = true
}
return Config{
display: display,
addr: addr,
saveNotRecognized: sNR,
collectSamples: cS,
saveImages: sI,
}
}
func main() {
config := gatherConfig()
mapCoordinates(config)
}