Updated vendor package github.com/cheggaaa/pb to v1.0.22
This commit is contained in:
parent
16ecb3ad9a
commit
ac27e54c95
36
vendor/github.com/cheggaaa/pb/pb.go
generated
vendored
36
vendor/github.com/cheggaaa/pb/pb.go
generated
vendored
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Current version
|
// Current version
|
||||||
const Version = "1.0.19"
|
const Version = "1.0.22"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Default refresh rate - 200ms
|
// Default refresh rate - 200ms
|
||||||
@ -37,16 +37,17 @@ func New(total int) *ProgressBar {
|
|||||||
// Create new progress bar object using int64 as total
|
// Create new progress bar object using int64 as total
|
||||||
func New64(total int64) *ProgressBar {
|
func New64(total int64) *ProgressBar {
|
||||||
pb := &ProgressBar{
|
pb := &ProgressBar{
|
||||||
Total: total,
|
Total: total,
|
||||||
RefreshRate: DEFAULT_REFRESH_RATE,
|
RefreshRate: DEFAULT_REFRESH_RATE,
|
||||||
ShowPercent: true,
|
ShowPercent: true,
|
||||||
ShowCounters: true,
|
ShowCounters: true,
|
||||||
ShowBar: true,
|
ShowBar: true,
|
||||||
ShowTimeLeft: true,
|
ShowTimeLeft: true,
|
||||||
ShowFinalTime: true,
|
ShowElapsedTime: false,
|
||||||
Units: U_NO,
|
ShowFinalTime: true,
|
||||||
ManualUpdate: false,
|
Units: U_NO,
|
||||||
finish: make(chan struct{}),
|
ManualUpdate: false,
|
||||||
|
finish: make(chan struct{}),
|
||||||
}
|
}
|
||||||
return pb.Format(FORMAT)
|
return pb.Format(FORMAT)
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ type ProgressBar struct {
|
|||||||
RefreshRate time.Duration
|
RefreshRate time.Duration
|
||||||
ShowPercent, ShowCounters bool
|
ShowPercent, ShowCounters bool
|
||||||
ShowSpeed, ShowTimeLeft, ShowBar bool
|
ShowSpeed, ShowTimeLeft, ShowBar bool
|
||||||
ShowFinalTime bool
|
ShowFinalTime, ShowElapsedTime bool
|
||||||
Output io.Writer
|
Output io.Writer
|
||||||
Callback Callback
|
Callback Callback
|
||||||
NotPrint bool
|
NotPrint bool
|
||||||
@ -274,7 +275,7 @@ func (pb *ProgressBar) NewProxyReader(r io.Reader) *Reader {
|
|||||||
func (pb *ProgressBar) write(current int64) {
|
func (pb *ProgressBar) write(current int64) {
|
||||||
width := pb.GetWidth()
|
width := pb.GetWidth()
|
||||||
|
|
||||||
var percentBox, countersBox, timeLeftBox, speedBox, barBox, end, out string
|
var percentBox, countersBox, timeLeftBox, timeSpentBox, speedBox, barBox, end, out string
|
||||||
|
|
||||||
// percents
|
// percents
|
||||||
if pb.ShowPercent {
|
if pb.ShowPercent {
|
||||||
@ -305,6 +306,11 @@ func (pb *ProgressBar) write(current int64) {
|
|||||||
lastChangeTime := pb.changeTime
|
lastChangeTime := pb.changeTime
|
||||||
fromChange := lastChangeTime.Sub(pb.startTime)
|
fromChange := lastChangeTime.Sub(pb.startTime)
|
||||||
pb.mu.Unlock()
|
pb.mu.Unlock()
|
||||||
|
|
||||||
|
if pb.ShowElapsedTime {
|
||||||
|
timeSpentBox = fmt.Sprintf(" %s ", (fromStart/time.Second)*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-pb.finish:
|
case <-pb.finish:
|
||||||
if pb.ShowFinalTime {
|
if pb.ShowFinalTime {
|
||||||
@ -342,7 +348,7 @@ func (pb *ProgressBar) write(current int64) {
|
|||||||
speedBox = " " + Format(int64(speed)).To(pb.Units).Width(pb.UnitsWidth).PerSec().String()
|
speedBox = " " + Format(int64(speed)).To(pb.Units).Width(pb.UnitsWidth).PerSec().String()
|
||||||
}
|
}
|
||||||
|
|
||||||
barWidth := escapeAwareRuneCountInString(countersBox + pb.BarStart + pb.BarEnd + percentBox + timeLeftBox + speedBox + pb.prefix + pb.postfix)
|
barWidth := escapeAwareRuneCountInString(countersBox + pb.BarStart + pb.BarEnd + percentBox + timeSpentBox + timeLeftBox + speedBox + pb.prefix + pb.postfix)
|
||||||
// bar
|
// bar
|
||||||
if pb.ShowBar {
|
if pb.ShowBar {
|
||||||
size := width - barWidth
|
size := width - barWidth
|
||||||
@ -387,7 +393,7 @@ func (pb *ProgressBar) write(current int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check len
|
// check len
|
||||||
out = pb.prefix + countersBox + barBox + percentBox + speedBox + timeLeftBox + pb.postfix
|
out = pb.prefix + timeSpentBox + countersBox + barBox + percentBox + speedBox + timeLeftBox + pb.postfix
|
||||||
if cl := escapeAwareRuneCountInString(out); cl < width {
|
if cl := escapeAwareRuneCountInString(out); cl < width {
|
||||||
end = strings.Repeat(" ", width-cl)
|
end = strings.Repeat(" ", width-cl)
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/cheggaaa/pb/pb_win.go
generated
vendored
2
vendor/github.com/cheggaaa/pb/pb_win.go
generated
vendored
@ -102,7 +102,7 @@ var echoLockMutex sync.Mutex
|
|||||||
|
|
||||||
var oldState word
|
var oldState word
|
||||||
|
|
||||||
func lockEcho() (quit chan int, err error) {
|
func lockEcho() (shutdownCh chan struct{}, err error) {
|
||||||
echoLockMutex.Lock()
|
echoLockMutex.Lock()
|
||||||
defer echoLockMutex.Unlock()
|
defer echoLockMutex.Unlock()
|
||||||
if echoLocked {
|
if echoLocked {
|
||||||
|
16
vendor/github.com/cheggaaa/pb/pb_x.go
generated
vendored
16
vendor/github.com/cheggaaa/pb/pb_x.go
generated
vendored
@ -48,21 +48,21 @@ func terminalWidth() (int, error) {
|
|||||||
return int(ws.Col), nil
|
return int(ws.Col), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func lockEcho() (quit chan int, err error) {
|
func lockEcho() (shutdownCh chan struct{}, err error) {
|
||||||
echoLockMutex.Lock()
|
echoLockMutex.Lock()
|
||||||
defer echoLockMutex.Unlock()
|
defer echoLockMutex.Unlock()
|
||||||
if origTermStatePtr != nil {
|
if origTermStatePtr != nil {
|
||||||
return quit, ErrPoolWasStarted
|
return shutdownCh, ErrPoolWasStarted
|
||||||
}
|
}
|
||||||
|
|
||||||
fd := int(tty.Fd())
|
fd := int(tty.Fd())
|
||||||
|
|
||||||
oldTermStatePtr, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
|
origTermStatePtr, err = unix.IoctlGetTermios(fd, ioctlReadTermios)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Can't get terminal settings: %v", err)
|
return nil, fmt.Errorf("Can't get terminal settings: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
oldTermios := *oldTermStatePtr
|
oldTermios := *origTermStatePtr
|
||||||
newTermios := oldTermios
|
newTermios := oldTermios
|
||||||
newTermios.Lflag &^= syscall.ECHO
|
newTermios.Lflag &^= syscall.ECHO
|
||||||
newTermios.Lflag |= syscall.ICANON | syscall.ISIG
|
newTermios.Lflag |= syscall.ICANON | syscall.ISIG
|
||||||
@ -71,8 +71,8 @@ func lockEcho() (quit chan int, err error) {
|
|||||||
return nil, fmt.Errorf("Can't set terminal settings: %v", err)
|
return nil, fmt.Errorf("Can't set terminal settings: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
quit = make(chan int, 1)
|
shutdownCh = make(chan struct{})
|
||||||
go catchTerminate(quit)
|
go catchTerminate(shutdownCh)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,12 +95,12 @@ func unlockEcho() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// listen exit signals and restore terminal state
|
// listen exit signals and restore terminal state
|
||||||
func catchTerminate(quit chan int) {
|
func catchTerminate(shutdownCh chan struct{}) {
|
||||||
sig := make(chan os.Signal, 1)
|
sig := make(chan os.Signal, 1)
|
||||||
signal.Notify(sig, os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL)
|
signal.Notify(sig, os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL)
|
||||||
defer signal.Stop(sig)
|
defer signal.Stop(sig)
|
||||||
select {
|
select {
|
||||||
case <-quit:
|
case <-shutdownCh:
|
||||||
unlockEcho()
|
unlockEcho()
|
||||||
case <-sig:
|
case <-sig:
|
||||||
unlockEcho()
|
unlockEcho()
|
||||||
|
48
vendor/github.com/cheggaaa/pb/pool.go
generated
vendored
48
vendor/github.com/cheggaaa/pb/pool.go
generated
vendored
@ -12,19 +12,28 @@ import (
|
|||||||
// You need call pool.Stop() after work
|
// You need call pool.Stop() after work
|
||||||
func StartPool(pbs ...*ProgressBar) (pool *Pool, err error) {
|
func StartPool(pbs ...*ProgressBar) (pool *Pool, err error) {
|
||||||
pool = new(Pool)
|
pool = new(Pool)
|
||||||
if err = pool.start(); err != nil {
|
if err = pool.Start(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pool.Add(pbs...)
|
pool.Add(pbs...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPool initialises a pool with progress bars, but
|
||||||
|
// doesn't start it. You need to call Start manually
|
||||||
|
func NewPool(pbs ...*ProgressBar) (pool *Pool) {
|
||||||
|
pool = new(Pool)
|
||||||
|
pool.Add(pbs...)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
Output io.Writer
|
Output io.Writer
|
||||||
RefreshRate time.Duration
|
RefreshRate time.Duration
|
||||||
bars []*ProgressBar
|
bars []*ProgressBar
|
||||||
lastBarsCount int
|
lastBarsCount int
|
||||||
quit chan int
|
shutdownCh chan struct{}
|
||||||
|
workerCh chan struct{}
|
||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
finishOnce sync.Once
|
finishOnce sync.Once
|
||||||
}
|
}
|
||||||
@ -41,30 +50,38 @@ func (p *Pool) Add(pbs ...*ProgressBar) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) start() (err error) {
|
func (p *Pool) Start() (err error) {
|
||||||
p.RefreshRate = DefaultRefreshRate
|
p.RefreshRate = DefaultRefreshRate
|
||||||
quit, err := lockEcho()
|
p.shutdownCh, err = lockEcho()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.quit = make(chan int)
|
p.workerCh = make(chan struct{})
|
||||||
go p.writer(quit)
|
go p.writer()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) writer(finish chan int) {
|
func (p *Pool) writer() {
|
||||||
var first = true
|
var first = true
|
||||||
|
defer func() {
|
||||||
|
if first == false {
|
||||||
|
p.print(false)
|
||||||
|
} else {
|
||||||
|
p.print(true)
|
||||||
|
p.print(false)
|
||||||
|
}
|
||||||
|
close(p.workerCh)
|
||||||
|
}()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-time.After(p.RefreshRate):
|
case <-time.After(p.RefreshRate):
|
||||||
if p.print(first) {
|
if p.print(first) {
|
||||||
p.print(false)
|
p.print(false)
|
||||||
finish <- 1
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
first = false
|
first = false
|
||||||
case <-p.quit:
|
case <-p.shutdownCh:
|
||||||
finish <- 1
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,11 +89,14 @@ func (p *Pool) writer(finish chan int) {
|
|||||||
|
|
||||||
// Restore terminal state and close pool
|
// Restore terminal state and close pool
|
||||||
func (p *Pool) Stop() error {
|
func (p *Pool) Stop() error {
|
||||||
// Wait until one final refresh has passed.
|
|
||||||
time.Sleep(p.RefreshRate)
|
|
||||||
|
|
||||||
p.finishOnce.Do(func() {
|
p.finishOnce.Do(func() {
|
||||||
close(p.quit)
|
close(p.shutdownCh)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Wait for the worker to complete
|
||||||
|
select {
|
||||||
|
case <-p.workerCh:
|
||||||
|
}
|
||||||
|
|
||||||
return unlockEcho()
|
return unlockEcho()
|
||||||
}
|
}
|
||||||
|
14
vendor/vendor.json
vendored
14
vendor/vendor.json
vendored
@ -585,18 +585,20 @@
|
|||||||
"path": "github.com/biogo/hts/bgzf",
|
"path": "github.com/biogo/hts/bgzf",
|
||||||
"revision": "50da7d4131a3b5c9d063932461cab4d1fafb20b0"
|
"revision": "50da7d4131a3b5c9d063932461cab4d1fafb20b0"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "A/OK8uWTeJYUL6XXFwOLWw1IZLQ=",
|
||||||
|
"path": "github.com/cheggaaa/pb",
|
||||||
|
"revision": "72b964305fba1230d3d818711138195f22b9ceea",
|
||||||
|
"revisionTime": "2018-02-18T15:37:33Z",
|
||||||
|
"version": "v1.0.22",
|
||||||
|
"versionExact": "v1.0.22"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "X2/71FBrn4pA3WcA620ySVO0uHU=",
|
"checksumSHA1": "X2/71FBrn4pA3WcA620ySVO0uHU=",
|
||||||
"path": "github.com/creack/goselect",
|
"path": "github.com/creack/goselect",
|
||||||
"revision": "528c74964609a58f7c17471525659c9b71cd499b",
|
"revision": "528c74964609a58f7c17471525659c9b71cd499b",
|
||||||
"revisionTime": "2018-02-10T03:43:46Z"
|
"revisionTime": "2018-02-10T03:43:46Z"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"checksumSHA1": "ymc5+iJ+1ipls3ihqPdzMjFYCqo=",
|
|
||||||
"path": "github.com/cheggaaa/pb",
|
|
||||||
"revision": "18d384da9bdc1e5a08fc2a62a494c321d9ae74ea",
|
|
||||||
"revisionTime": "2017-12-14T13:20:59Z"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"checksumSHA1": "/5cvgU+J4l7EhMXTK76KaCAfOuU=",
|
"checksumSHA1": "/5cvgU+J4l7EhMXTK76KaCAfOuU=",
|
||||||
"comment": "v1.0.0-3-g6d21280",
|
"comment": "v1.0.0-3-g6d21280",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user