-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Initially I commented on #607 , but I then found out, that I can't reopen it, hence I decided to create a dedicated issue. I apologize if that's an unwanted noise.
Right now Command
offers SetOutput
method to set alternative io.Writer
implementation for testing stdout/stderr interaction.
I think it would be great to be able to distinct standard output and error output here.
It is not uncommong for commands to report warnings to stderr. For example, take GNU's ls
$ ls -l /does/not/exist /tmp
ls: cannot access '/does/not/exist': No such file or directory
/tmp:
total 27776
...
If I were to reimplement this in go, I'd want to be sure, that ls: cannot access ...
won't get to stdout, as it may be piped further. So I'd like to have test for that. With current cobra code it is not possible to test this behavior.
It looks like a very straightforward and simple change and we can even make it backward compatible with current API.
If there's interest and/or maintainers are open for this change, I'd be willing to work on it.