mirror of
https://github.com/spf13/cobra
synced 2025-05-07 22:07:23 +00:00
Still include SetOutput as it is exported
This reverts commit 6291af1f4d
.
This commit is contained in:
parent
044950bbc1
commit
6a174752ba
2 changed files with 16 additions and 0 deletions
|
@ -218,6 +218,14 @@ func (c *Command) SetArgs(a []string) {
|
||||||
c.args = a
|
c.args = a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetOutput sets the destination for usage and error messages.
|
||||||
|
// If output is nil, os.Stderr is used.
|
||||||
|
// Deprecated: Use SetOut and/or SetErr instead
|
||||||
|
func (c *Command) SetOutput(output io.Writer) {
|
||||||
|
c.outWriter = output
|
||||||
|
c.errWriter = output
|
||||||
|
}
|
||||||
|
|
||||||
// SetOut sets the destination for usage messages.
|
// SetOut sets the destination for usage messages.
|
||||||
// If newOut is nil, os.Stdout is used.
|
// If newOut is nil, os.Stdout is used.
|
||||||
func (c *Command) SetOut(newOut io.Writer) {
|
func (c *Command) SetOut(newOut io.Writer) {
|
||||||
|
|
|
@ -1557,6 +1557,14 @@ func TestEnableCommandSortingIsDisabled(t *testing.T) {
|
||||||
EnableCommandSorting = true
|
EnableCommandSorting = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSetOutput(t *testing.T) {
|
||||||
|
c := &Command{}
|
||||||
|
c.SetOutput(nil)
|
||||||
|
if out := c.OutOrStdout(); out != os.Stdout {
|
||||||
|
t.Errorf("Expected setting output to nil to revert back to stdout")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSetOut(t *testing.T) {
|
func TestSetOut(t *testing.T) {
|
||||||
c := &Command{}
|
c := &Command{}
|
||||||
c.SetOut(nil)
|
c.SetOut(nil)
|
||||||
|
|
Loading…
Add table
Reference in a new issue