This repository has been archived by the owner on Jun 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
86 lines (71 loc) · 2.42 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
package main
import (
"flag"
)
type Flags struct {
verbose string
unityURL string
APIURL string
APIKEY string
listenPort int
envPath string
histPath string
script string
}
// Assign value to flag with preference to 'x'
func NonDefault[T comparable](x, y, defaultValue T) T {
if x != defaultValue {
return x
} else if y != defaultValue {
return y
} else {
return defaultValue
}
}
func main() {
var listenPORT, l int
var verboseLevel, v, unityURL, u, APIURL, a, APIKEY, k,
envPath, e, histPath, h, file, f string
flag.StringVar(&v, "v", "ERROR",
"Indicates level of debugging messages."+
"The levels are of in ascending order:"+
"{NONE,ERROR,WARNING,INFO,DEBUG}.")
flag.StringVar(&verboseLevel, "verbose", "ERROR",
"Indicates level of debugging messages."+
"The levels are of in ascending order:"+
"{NONE,ERROR,WARNING,INFO,DEBUG}.")
flag.StringVar(&unityURL, "unity_url", "", "Unity URL")
flag.StringVar(&u, "u", "", "Unity URL")
flag.StringVar(&APIURL, "api_url", "", "API URL")
flag.StringVar(&a, "a", "", "API URL")
flag.IntVar(&listenPORT, "listen_port", 0,
"Indicates which port to communicate to Unity")
flag.IntVar(&l, "l", 0,
"Indicates which port to communicate to Unity")
flag.StringVar(&APIKEY, "api_key", "", "Indicate the key of the API")
flag.StringVar(&k, "k", "", "Indicate the key of the API")
flag.StringVar(&envPath, "env_path", "./.env",
"Indicate the location of the Shell's env file")
flag.StringVar(&e, "e", "./.env",
"Indicate the location of the Shell's env file")
flag.StringVar(&histPath, "history_path", "./.history",
"Indicate the location of the Shell's history file")
flag.StringVar(&h, "h", "./.history",
"Indicate the location of the Shell's history file")
flag.StringVar(&file, "file", "", "Launch the shell as an interpreter "+
" by only executing an OCLI script file")
flag.StringVar(&f, "f", "", "Launch the shell as an interpreter "+
" by only executing an OCLI script file")
flag.Parse()
var flags Flags
flags.verbose = NonDefault(v, verboseLevel, "ERROR")
flags.unityURL = NonDefault(u, unityURL, "")
flags.APIURL = NonDefault(a, APIURL, "")
flags.APIKEY = NonDefault(k, APIKEY, "")
flags.listenPort = NonDefault(l, listenPORT, 0)
flags.envPath = NonDefault(e, envPath, "./.env")
flags.histPath = NonDefault(h, histPath, "./.history")
flags.script = NonDefault(f, file, "")
//Pass control to repl.go
Start(&flags)
}