From 93a1972006a9f56dfda827b3261d9b236331a44c Mon Sep 17 00:00:00 2001 From: Karn Wong Date: Sat, 10 Aug 2024 10:42:39 +0700 Subject: [PATCH] fix: forgot to read config after initial config write --- cmd/root.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index ee511ce..362da06 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -62,13 +62,13 @@ func init() { if err != nil { log.Fatal().Err(err).Msg("Error obtaining home directory") } - err = os.MkdirAll(filepath.Join(homeDir, ".config", "wakatime-cli"), os.ModePerm) + err = os.MkdirAll(filepath.Join(homeDir, ".config", "waka"), os.ModePerm) if err != nil { log.Fatal().Err(err).Msg("Error creating config path") } //// write yaml - filename := filepath.Join(homeDir, ".config", "wakatime-cli", "config.yaml") + filename := filepath.Join(homeDir, ".config", "waka", "config.yaml") file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { log.Fatal().Err(err).Msg("Error creating config file") @@ -81,6 +81,13 @@ func init() { if err != nil { log.Fatal().Err(err).Msg("Error writing config") } + + // read config to viper + err = viper.ReadInConfig() + if err != nil { + log.Fatal().Err(err).Msg("Error reading config after config initialization") + } + } // rootCmd