-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (38 loc) · 963 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
44
45
46
package main
import (
"flag"
"fmt"
"os"
"queue-manager/internal/di"
"queue-manager/internal/structures"
)
const (
AppName = "QueueManager"
APPNameLower = "queue_manager"
Version = "0.0.1"
)
func main() {
// cli flags
cf := new(structures.CliFlags)
flag.StringVar(&cf.ConfigPath, "config", "/etc/"+APPNameLower+"/"+APPNameLower+".yml", "path to config")
flag.BoolVar(&cf.DebugMode, "debug", false, "debug mode")
flag.BoolVar(&cf.VersionPrint, "version", false, "print version")
flag.BoolVar(&cf.Help, "help", false, "show flags")
flag.BoolVar(&cf.TestMode, "test", false, "test mode")
flag.Parse()
if cf.VersionPrint {
ExitWithCode(fmt.Sprintf("%s Version: %s\n", AppName, Version), 0)
}
if cf.Help {
flag.PrintDefaults()
os.Exit(0)
}
_, err := di.InitApp(cf)
if err != nil {
ExitWithCode(fmt.Sprintf("Error app init: %v\n", err), 1)
}
}
func ExitWithCode(msg string, code int) {
fmt.Println(msg)
os.Exit(code)
}