Still include SetOutput as it is exported

This reverts commit 6291af1f4d.
This commit is contained in:
John McBride 2020-04-03 13:02:05 -06:00
parent 044950bbc1
commit 6a174752ba
2 changed files with 16 additions and 0 deletions

View file

@ -218,6 +218,14 @@ func (c *Command) SetArgs(a []string) {
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.
// If newOut is nil, os.Stdout is used.
func (c *Command) SetOut(newOut io.Writer) {

View file

@ -1557,6 +1557,14 @@ func TestEnableCommandSortingIsDisabled(t *testing.T) {
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) {
c := &Command{}
c.SetOut(nil)