github.com/pivotal-cf/go-pivnet/v6@v6.0.2/download/progress.go (about)

     1  package download
     2  
     3  import (
     4  	"io"
     5  
     6  	pb "gopkg.in/cheggaaa/pb.v1"
     7  	"time"
     8  )
     9  
    10  type Bar struct {
    11  	*pb.ProgressBar
    12  }
    13  
    14  func NewBar() Bar {
    15  	b := pb.New(0)
    16  	b.SetUnits(pb.U_BYTES)
    17  	b.SetWidth(80)
    18  	b.SetRefreshRate(2 * time.Second)
    19  	return Bar{b}
    20  }
    21  
    22  func (b Bar) SetTotal(contentLength int64) {
    23  	b.Total = contentLength
    24  }
    25  
    26  func (b Bar) Kickoff() {
    27  	b.Start()
    28  }
    29  
    30  func (b Bar) SetOutput(output io.Writer) {
    31  	b.Output = output
    32  }
    33  
    34  func (b Bar) NewProxyReader(reader io.Reader) (io.Reader) {
    35  	return b.ProgressBar.NewProxyReader(reader)
    36  }