]> git.r.bdr.sh - rbdr/mobius/blobdiff - client/main.go
Add per-OS default config path to accomodate Windows
[rbdr/mobius] / client / main.go
index 3ce4c7ed142a73f251c094a75674fbad44625dad..ec6f8951eb0380868e6209e0179f2958d9ac988f 100644 (file)
@@ -11,10 +11,10 @@ import (
        "log"
        "os"
        "os/signal"
        "log"
        "os"
        "os/signal"
+       "runtime"
        "syscall"
 )
 
        "syscall"
 )
 
-
 func main() {
        _, cancelRoot := context.WithCancel(context.Background())
 
 func main() {
        _, cancelRoot := context.WithCancel(context.Background())
 
@@ -70,7 +70,9 @@ func main() {
                cancelRoot()
        }()
 
                cancelRoot()
        }()
 
-       client := hotline.NewClient("", logger)
+       cfgPath := defaultConfigPath()
+
+       client := hotline.NewClient(cfgPath, logger)
        client.DebugBuf = db
        client.UI.Start()
 
        client.DebugBuf = db
        client.UI.Start()
 
@@ -94,3 +96,19 @@ var zapLogLevel = map[string]zapcore.Level{
        "warn":  zap.WarnLevel,
        "error": zap.ErrorLevel,
 }
        "warn":  zap.WarnLevel,
        "error": zap.ErrorLevel,
 }
+
+func defaultConfigPath() (cfgPath string) {
+       os := runtime.GOOS
+       switch os {
+       case "windows":
+               cfgPath = "mobius-client-config.yaml"
+       case "darwin":
+               cfgPath = "/usr/local/etc/mobius-client-config.yaml"
+       case "linux":
+               cfgPath = "/usr/local/etc/mobius-client-config.yaml"
+       default:
+               fmt.Printf("unsupported OS")
+       }
+
+       return cfgPath
+}