]> 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 6008cad5ac67c20bcd57133a12c4ec4f954aab2e..ec6f8951eb0380868e6209e0179f2958d9ac988f 100644 (file)
@@ -4,13 +4,14 @@ import (
        "context"
        "flag"
        "fmt"
        "context"
        "flag"
        "fmt"
-       hotline "github.com/jhalter/mobius"
+       "github.com/jhalter/mobius/hotline"
        "github.com/rivo/tview"
        "go.uber.org/zap"
        "go.uber.org/zap/zapcore"
        "log"
        "os"
        "os/signal"
        "github.com/rivo/tview"
        "go.uber.org/zap"
        "go.uber.org/zap/zapcore"
        "log"
        "os"
        "os/signal"
+       "runtime"
        "syscall"
 )
 
        "syscall"
 )
 
@@ -69,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()
 
@@ -93,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
+}