From 0beb1b63ceea0d123f90f9e0f2940a5ff563f91a Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 17 Jun 2024 12:10:13 +0200 Subject: [PATCH] Silence config warnings in text mode except for 'config ...' commands --- main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index fa29df9c148..3bf2fdd77be 100644 --- a/main.go +++ b/main.go @@ -76,8 +76,14 @@ func main() { if parentPreRun != nil { parentPreRun(cmd, args) } - for _, warning := range configFileLoadingWarnings { - feedback.Warning(warning) + + // In Text mode print the warnings about the configuration file + // only if we are inside the "config ..." command. In JSON mode always + // output the warning. + if feedback.GetFormat() != feedback.Text || (cmd.HasParent() && cmd.Parent().Name() == "config") { + for _, warning := range configFileLoadingWarnings { + feedback.Warning(fmt.Sprintf("%s: %s", i18n.Tr("Invalid value in configuration"), warning)) + } } }