mirror of
https://github.com/spf13/cobra
synced 2024-12-26 22:37:08 +00:00
feat: create PrintOut() - deprecate Print()
This commit is contained in:
parent
e80bdb9a8c
commit
1374825960
1 changed files with 18 additions and 0 deletions
18
command.go
18
command.go
|
@ -1414,20 +1414,38 @@ main:
|
|||
}
|
||||
|
||||
// Print is a convenience method to Print to the defined output, fallback to Stderr if not set.
|
||||
// Deprecated: Use PrintOut or PrintErr instead.
|
||||
func (c *Command) Print(i ...interface{}) {
|
||||
fmt.Fprint(c.OutOrStderr(), i...)
|
||||
}
|
||||
|
||||
// Println is a convenience method to Println to the defined output, fallback to Stderr if not set.
|
||||
// Deprecated: Use PrintOutln or PrintErrln instead.
|
||||
func (c *Command) Println(i ...interface{}) {
|
||||
c.Print(fmt.Sprintln(i...))
|
||||
}
|
||||
|
||||
// Printf is a convenience method to Printf to the defined output, fallback to Stderr if not set.
|
||||
// Deprecated: Use PrintOutf or PrintErrf instead.
|
||||
func (c *Command) Printf(format string, i ...interface{}) {
|
||||
c.Print(fmt.Sprintf(format, i...))
|
||||
}
|
||||
|
||||
// PrintOut is a convenience method to Print to the defined OutStream, fallback to Stdout if not set.
|
||||
func (c *Command) PrintOut(i ...interface{}) {
|
||||
fmt.Fprint(c.OutOrStdout(), i...)
|
||||
}
|
||||
|
||||
// PrintOutln is a convenience method to Println to the defined OutStream, fallback to Stdout if not set.
|
||||
func (c *Command) PrintOutln(i ...interface{}) {
|
||||
c.PrintOut(fmt.Sprintln(i...))
|
||||
}
|
||||
|
||||
// PrintOutf is a convenience method to Printf to the defined OutStream, fallback to Stdout if not set.
|
||||
func (c *Command) PrintOutf(format string, i ...interface{}) {
|
||||
c.PrintOut(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...)
|
||||
|
|
Loading…
Reference in a new issue