Codebase list golang-github-vbauerster-mpb / 93f89a7
SetOut Vladimir Bauer 9 years ago
1 changed file(s) with 10 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
99 )
1010
1111 // Out is the default writer to render progress bars to
12 var Out = os.Stdout
12 // var Out = os.Stdout
1313
1414 // RefreshInterval in the default time duration to wait for refreshing the output
1515 var RefreshInterval = time.Millisecond * 10
1717 // Progress represents the container that renders progress bars
1818 type Progress struct {
1919 // Out is the writer to render progress bars to
20 Out io.Writer
20 out io.Writer
2121
2222 // Width is the width of the progress bars
2323 // Width int
3838 // New returns a new progress bar with defaults
3939 func New() *Progress {
4040 p := &Progress{
41 Out: Out,
41 out: os.Stdout,
4242 lw: uilive.New(),
4343 bars: make(chan *Bar),
4444 ticker: time.NewTicker(RefreshInterval),
4545 }
4646 go p.server()
47 return p
48 }
49
50 // SetOut is the writer to render progress bars to
51 func (p *Progress) SetOut(w io.Writer) *Progress {
52 p.out = w
4753 return p
4854 }
4955
5864 // Listen listens for updates and renders the progress bars
5965 func (p *Progress) server() {
6066 bars := make([]*Bar, 0)
61 p.lw.Out = p.Out
67 p.lw.Out = p.out
6268 loop:
6369 for {
6470 select {