From 2450b1d191914c046dda156dfded2cc0751abc3b Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sat, 4 Nov 2023 18:50:13 +0100 Subject: [PATCH] Don't print informational values to stdout (#1472) The first message can probably be just removed. The primary reason I want to remove these is that it makes piping `-ojson` output to `jq` which I think should just print JSON and nothing else. --- cmd/cli/app/root.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/cli/app/root.go b/cmd/cli/app/root.go index 0abaa1e078..2abd7f22f3 100644 --- a/cmd/cli/app/root.go +++ b/cmd/cli/app/root.go @@ -18,6 +18,7 @@ package app import ( "fmt" + "os" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -77,10 +78,10 @@ func initConfig() { if err := viper.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); ok { // Config file not found; use default values - fmt.Println("No config file present, using default values.") + fmt.Fprintln(os.Stderr, "No config file present, using default values.") } else { // Some other error occurred - fmt.Println("Error reading config file:", err) + fmt.Fprintln(os.Stderr, "Error reading config file:", err) } } }