Skip to content

Commit 23579e7

Browse files
committed
Turn on SilenceErrors and SilenceUsage to prevent Cobra from messing up the stderr output
Signed-off-by: Richard Wall <[email protected]>
1 parent cd4dd90 commit 23579e7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/root.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ Preflight checks are bundled into Packages`,
2323
PersistentPreRun: func(cmd *cobra.Command, args []string) {
2424
logs.Initialize()
2525
},
26+
// SilenceErrors and SilenceUsage prevents this command or any sub-command
27+
// from printing arbitrary text to stderr.
28+
// Why? To ensure that each line of output can be parsed as a single message
29+
// for consumption by logging agents such as fluentd.
30+
// Usage information is still available on stdout with the `-h` and `--help`
31+
// flags.
32+
SilenceErrors: true,
33+
SilenceUsage: true,
2634
}
2735

2836
func init() {

0 commit comments

Comments
 (0)