minor: WithOutput refactoring
Vladimir Bauer
3 years ago
| 71 | 71 | // will effectively disable auto refresh rate and discard any output, |
| 72 | 72 | // useful if you want to disable progress bars with little overhead. |
| 73 | 73 | func WithOutput(w io.Writer) ContainerOption { |
| 74 | var discarded bool | |
| 75 | if w == nil { | |
| 76 | w = io.Discard | |
| 77 | discarded = true | |
| 78 | } | |
| 74 | 79 | return func(s *pState) { |
| 75 | if w == nil { | |
| 76 | s.output = io.Discard | |
| 77 | s.outputDiscarded = true | |
| 78 | return | |
| 79 | } | |
| 80 | 80 | s.output = w |
| 81 | s.outputDiscarded = discarded | |
| 81 | 82 | } |
| 82 | 83 | } |
| 83 | 84 |