diff --git a/cmd/main.go b/cmd/main.go index 17701ed4c..1ca2526f5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -146,10 +146,10 @@ func exitIfError(err error) { if err != nil { switch e := err.(type) { case *wrappers.AstError: - fmt.Println(e.Err) + fmt.Fprintln(os.Stderr, e.Err) os.Exit(e.Code) default: - fmt.Println(e) + fmt.Fprintln(os.Stderr, e) os.Exit(failureExitCode) } } diff --git a/internal/commands/root.go b/internal/commands/root.go index 1613c5fbd..02feca78a 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -242,6 +242,8 @@ func NewAstCLI( ) rootCmd.SilenceUsage = true + // Avoid Cobra printing the error in addition to our own handling in main + rootCmd.SilenceErrors = true return rootCmd }