Skip to content

Commit

Permalink
Errors go to stderr as per POSIX
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio authored and Alessio Treglia committed Aug 10, 2019
1 parent 59bb8be commit 0da6ddb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (c *Command) UsageFunc() (f func(*Command) error) {
c.mergePersistentFlags()
err := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)
if err != nil {
c.Println(err)
c.PrintErrln(err)
}
return err
}
Expand All @@ -374,7 +374,7 @@ func (c *Command) HelpFunc() func(*Command, []string) {
c.mergePersistentFlags()
err := tmpl(c.OutOrStderr(), c.HelpTemplate(), c)
if err != nil {
c.Println(err)
c.PrintErrln(err)
}
}
}
Expand Down Expand Up @@ -903,8 +903,8 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
c = cmd
}
if !c.SilenceErrors {
c.Println("Error:", err.Error())
c.Printf("Run '%v --help' for usage.\n", c.CommandPath())
c.PrintErrln("Error:", err.Error())
c.PrintErr(fmt.Sprintf("Run '%v --help' for usage.\n", c.CommandPath()))
}
return c, err
}
Expand Down Expand Up @@ -934,7 +934,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
// If root command has SilentErrors flagged,
// all subcommands should respect it
if !cmd.SilenceErrors && !c.SilenceErrors {
c.Println("Error:", err.Error())
c.PrintErrln("Error:", err.Error())
}

// If root command has SilentUsage flagged,
Expand Down

0 comments on commit 0da6ddb

Please sign in to comment.