2022-02-07 10:12:02 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import "os"
|
|
|
|
|
|
|
|
var usage = []string{
|
|
|
|
"\n" + Title + " v" + Version + " Usage\n",
|
|
|
|
"-c <config.toml> - Specify config file",
|
|
|
|
"--nocolor - disable color and banner ",
|
|
|
|
"--banner - show banner + version and exit",
|
|
|
|
"--genconfig - write default config to 'default.toml' then exit",
|
|
|
|
}
|
|
|
|
|
|
|
|
func printUsage() {
|
|
|
|
println(usage)
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2022-03-06 20:17:38 +00:00
|
|
|
var (
|
|
|
|
forceDebug = false
|
|
|
|
forceTrace = false
|
|
|
|
)
|
|
|
|
|
2022-02-07 10:12:02 +00:00
|
|
|
// TODO: should probably just make a proper CLI with flags or something
|
|
|
|
func argParse() {
|
|
|
|
for i, arg := range os.Args {
|
|
|
|
switch arg {
|
|
|
|
case "-h":
|
|
|
|
printUsage()
|
|
|
|
case "--genconfig":
|
|
|
|
GenConfig = true
|
2022-03-06 20:17:38 +00:00
|
|
|
case "--debug", "-v":
|
2022-03-06 20:03:36 +00:00
|
|
|
forceDebug = true
|
2022-03-06 20:17:38 +00:00
|
|
|
case "--trace", "-vv":
|
2022-03-06 20:03:36 +00:00
|
|
|
forceTrace = true
|
2022-02-07 10:12:02 +00:00
|
|
|
case "--nocolor":
|
|
|
|
noColorForce = true
|
|
|
|
case "--banner":
|
|
|
|
BannerOnly = true
|
|
|
|
case "-c", "--config":
|
|
|
|
if len(os.Args) <= i-1 {
|
|
|
|
panic("syntax error! expected file after -c")
|
|
|
|
}
|
|
|
|
loadCustomConfig(os.Args[i+1])
|
|
|
|
default:
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|