mirror of
https://github.com/spf13/cobra
synced 2024-12-27 14:57:06 +00:00
Allow for explicit output to err/stderr
This commit is contained in:
parent
0ea93dd60d
commit
618bc00f80
1 changed files with 15 additions and 0 deletions
15
command.go
15
command.go
|
@ -1121,6 +1121,21 @@ func (c *Command) Printf(format string, i ...interface{}) {
|
|||
c.Print(fmt.Sprintf(format, i...))
|
||||
}
|
||||
|
||||
// PrintErr is a convenience method to Print to the defined Err output, fallback to Stderr if not set.
|
||||
func (c *Command) PrintErr(i ...interface{}) {
|
||||
fmt.Fprint(c.ErrOrStderr(), i...)
|
||||
}
|
||||
|
||||
// PrintErrln is a convenience method to Println to the defined Err output, fallback to Stderr if not set.
|
||||
func (c *Command) PrintErrln(i ...interface{}) {
|
||||
c.Print(fmt.Sprintln(i...))
|
||||
}
|
||||
|
||||
// PrintErrf is a convenience method to Printf to the defined Err output, fallback to Stderr if not set.
|
||||
func (c *Command) PrintErrf(format string, i ...interface{}) {
|
||||
c.Print(fmt.Sprintf(format, i...))
|
||||
}
|
||||
|
||||
// CommandPath returns the full path to this command.
|
||||
func (c *Command) CommandPath() string {
|
||||
if c.HasParent() {
|
||||
|
|
Loading…
Reference in a new issue