writer.go 744 B

1234567891011121314151617181920212223
  1. package commands
  2. import "io"
  3. // Output is where a command line surface's text goes.
  4. //
  5. // Out and Err are distinct so a command's primary output can stay machine readable on
  6. // a surface that separates the two. The ssh surface points both at the same channel and
  7. // sees a single merged stream. The local
  8. // control socket does not use one at all: it invokes by named parameter and carries the
  9. // returned value, so there is no stream for a command to write to.
  10. type Output struct {
  11. // Out receives what a command produces.
  12. Out io.Writer
  13. // Err receives usage text, refusals and errors.
  14. Err io.Writer
  15. }
  16. // MergedOutput sends output and errors to the same writer.
  17. func MergedOutput(w io.Writer) Output {
  18. return Output{Out: w, Err: w}
  19. }