Skip to content

Commit

Permalink
Silence config warnings in text mode except for 'config ...' commands
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Jun 17, 2024
1 parent c9c90df commit 0beb1b6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}

Expand Down

0 comments on commit 0beb1b6

Please sign in to comment.