From 95753255a17026750f5b53cc470999785e0c515f Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Wed, 28 Jul 2021 18:17:13 -0700 Subject: Add per-OS default config path to accomodate Windows --- client/main.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/main.go b/client/main.go index 3ce4c7e..ec6f895 100644 --- a/client/main.go +++ b/client/main.go @@ -11,10 +11,10 @@ import ( "log" "os" "os/signal" + "runtime" "syscall" ) - func main() { _, cancelRoot := context.WithCancel(context.Background()) @@ -70,7 +70,9 @@ func main() { cancelRoot() }() - client := hotline.NewClient("", logger) + cfgPath := defaultConfigPath() + + client := hotline.NewClient(cfgPath, logger) client.DebugBuf = db client.UI.Start() @@ -94,3 +96,19 @@ var zapLogLevel = map[string]zapcore.Level{ "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 +} -- cgit