From c9a5306f6e7b05c9b31e760672117039c6d8fa0b Mon Sep 17 00:00:00 2001 From: Dinesh Date: Fri, 13 Dec 2019 11:44:42 +0530 Subject: [PATCH] Print 'Using config file' only for generate sub-command Signed-off-by: Dinesh --- cmd/generate.go | 1 + cmd/root.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/generate.go b/cmd/generate.go index 307aba2..0502bfa 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -24,6 +24,7 @@ var generateCmd = &cobra.Command{ os.Exit(1) } + fmt.Println("Using config file:", cfgFile) kubetmuxpCfg, err := kubetmuxp.NewConfig(cfgFile, fs, kubeCfg) if err != nil { fmt.Println(err) diff --git a/cmd/root.go b/cmd/root.go index cab70fe..3601332 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -43,7 +43,7 @@ func initConfig() { viper.AutomaticEnv() - if err := viper.ReadInConfig(); err == nil { - fmt.Println("Using config file:", viper.ConfigFileUsed()) + if err := viper.ReadInConfig(); err != nil { + _, _ = fmt.Fprintln(os.Stderr, fmt.Sprintf("error reading config file %s: %v", viper.ConfigFileUsed(), err)) } }