mirror of
https://github.com/spf13/cobra
synced 2025-05-06 13:27:26 +00:00
Errors go to stderr as per POSIX
This commit is contained in:
parent
59bb8be6ad
commit
0da6ddb27b
1 changed files with 5 additions and 5 deletions
10
command.go
10
command.go
|
@ -348,7 +348,7 @@ func (c *Command) UsageFunc() (f func(*Command) error) {
|
||||||
c.mergePersistentFlags()
|
c.mergePersistentFlags()
|
||||||
err := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)
|
err := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Println(err)
|
c.PrintErrln(err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ func (c *Command) HelpFunc() func(*Command, []string) {
|
||||||
c.mergePersistentFlags()
|
c.mergePersistentFlags()
|
||||||
err := tmpl(c.OutOrStderr(), c.HelpTemplate(), c)
|
err := tmpl(c.OutOrStderr(), c.HelpTemplate(), c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Println(err)
|
c.PrintErrln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -903,8 +903,8 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
||||||
c = cmd
|
c = cmd
|
||||||
}
|
}
|
||||||
if !c.SilenceErrors {
|
if !c.SilenceErrors {
|
||||||
c.Println("Error:", err.Error())
|
c.PrintErrln("Error:", err.Error())
|
||||||
c.Printf("Run '%v --help' for usage.\n", c.CommandPath())
|
c.PrintErr(fmt.Sprintf("Run '%v --help' for usage.\n", c.CommandPath()))
|
||||||
}
|
}
|
||||||
return c, err
|
return c, err
|
||||||
}
|
}
|
||||||
|
@ -934,7 +934,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
||||||
// If root command has SilentErrors flagged,
|
// If root command has SilentErrors flagged,
|
||||||
// all subcommands should respect it
|
// all subcommands should respect it
|
||||||
if !cmd.SilenceErrors && !c.SilenceErrors {
|
if !cmd.SilenceErrors && !c.SilenceErrors {
|
||||||
c.Println("Error:", err.Error())
|
c.PrintErrln("Error:", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// If root command has SilentUsage flagged,
|
// If root command has SilentUsage flagged,
|
||||||
|
|
Loading…
Add table
Reference in a new issue