Skip to content

Commit

Permalink
Merge pull request #15 from SimonBaeumer/remove-multiplexed-writer
Browse files Browse the repository at this point in the history
Replace multiplexed_writer with built-in io.MultiWriter
  • Loading branch information
SimonBaeumer committed Apr 1, 2020
2 parents ba20057 + d186d1c commit 3c50ae7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 92 deletions.
12 changes: 6 additions & 6 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func NewCommand(cmd string, options ...func(*Command)) *Command {
Env: []string{},
}

c.StdoutWriter = NewMultiplexedWriter(&c.stdout, &c.combined)
c.StderrWriter = NewMultiplexedWriter(&c.stderr, &c.combined)
c.StdoutWriter = io.MultiWriter(&c.stdout, &c.combined)
c.StderrWriter = io.MultiWriter(&c.stderr, &c.combined)

for _, o := range options {
o(c)
Expand All @@ -78,23 +78,23 @@ func NewCommand(cmd string, options ...func(*Command)) *Command {
// c.Execute()
//
func WithStandardStreams(c *Command) {
c.StdoutWriter = NewMultiplexedWriter(os.Stdout, &c.stdout, &c.combined)
c.StderrWriter = NewMultiplexedWriter(os.Stderr, &c.stdout, &c.combined)
c.StdoutWriter = io.MultiWriter(os.Stdout, &c.stdout, &c.combined)
c.StderrWriter = io.MultiWriter(os.Stderr, &c.stdout, &c.combined)
}

// WithCustomStdout allows to add custom writers to stdout
func WithCustomStdout(writers ...io.Writer) func(c *Command) {
return func(c *Command) {
writers = append(writers, &c.stdout, &c.combined)
c.StdoutWriter = NewMultiplexedWriter(writers...)
c.StdoutWriter = io.MultiWriter(writers...)
}
}

// WithCustomStderr allows to add custom writers to stderr
func WithCustomStderr(writers ...io.Writer) func(c *Command) {
return func(c *Command) {
writers = append(writers, &c.stderr, &c.combined)
c.StderrWriter = NewMultiplexedWriter(writers...)
c.StderrWriter = io.MultiWriter(writers...)
}
}

Expand Down
29 changes: 0 additions & 29 deletions multiplexed_writer.go

This file was deleted.

57 changes: 0 additions & 57 deletions multiplexed_writer_test.go

This file was deleted.

0 comments on commit 3c50ae7

Please sign in to comment.