Skip to content

Commit

Permalink
fix: do not create an output from an output
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Apr 12, 2023
1 parent 8514d90 commit 3912fa0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ func WithContext(ctx context.Context) ProgramOption {
// won't need to use this.
func WithOutput(output io.Writer) ProgramOption {
return func(p *Program) {
p.output = termenv.NewOutput(output, termenv.WithColorCache(true))
switch o := output.(type) {
case *termenv.Output:
p.output = o
default:
p.output = termenv.NewOutput(o, termenv.WithColorCache(true))
}
}
}

Expand Down

0 comments on commit 3912fa0

Please sign in to comment.