From 7138f6a87972fcf0dd7a70f87058f355432a9541 Mon Sep 17 00:00:00 2001 From: Youngjin Jo Date: Fri, 22 Nov 2024 19:02:19 +0900 Subject: [PATCH] chore: set globalConfig up Signed-off-by: Youngjin Jo --- cmd/other/config.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/other/config.go b/cmd/other/config.go index f018838..498aa5a 100644 --- a/cmd/other/config.go +++ b/cmd/other/config.go @@ -426,6 +426,20 @@ func getCurrentEnvironment(v *viper.Viper) string { // updateGlobalConfig prints a success message for global config update func updateGlobalConfig() { + configPath := filepath.Join(GetConfigDir(), "config.yaml") + v := viper.New() + + v.SetConfigFile(configPath) + + if err := v.ReadInConfig(); err != nil { + if os.IsNotExist(err) { + pterm.Success.WithShowLineNumber(false).Printfln("Global config updated with existing environments. (default: %s/config.yaml)", GetConfigDir()) + return + } + pterm.Warning.Printf("Warning: Could not read global config: %v\n", err) + return + } + pterm.Success.WithShowLineNumber(false).Printfln("Global config updated with existing environments. (default: %s/config.yaml)", GetConfigDir()) }