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 committed Jun 26, 2019
1 parent a54eec2 commit ec14f95
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 @@ -345,7 +345,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 @@ -371,7 +371,7 @@ func (c *Command) HelpFunc() func(*Command, []string) {
c.mergePersistentFlags()
err := tmpl(c.OutOrStdout(), c.HelpTemplate(), c)
if err != nil {
c.Println(err)
c.PrintErrln(err)
}
}
}
Expand Down Expand Up @@ -900,8 +900,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 All @@ -923,7 +923,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 ec14f95

Please sign in to comment.