Bump github.com/containers/image/v5 from 5.12.0 to 5.13.1

Bumps [github.com/containers/image/v5](https://github.com/containers/image) from 5.12.0 to 5.13.1.
- [Release notes](https://github.com/containers/image/releases)
- [Commits](https://github.com/containers/image/compare/v5.12.0...v5.13.1)

---
updated-dependencies:
- dependency-name: github.com/containers/image/v5
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2021-06-16 15:34:27 +00:00
committed by GitHub
parent 513a524d7d
commit abdc4a7e42
173 changed files with 4109 additions and 12689 deletions

View File

@@ -1,191 +0,0 @@
package mpb
import (
"bytes"
"io"
"unicode/utf8"
"github.com/mattn/go-runewidth"
"github.com/rivo/uniseg"
"github.com/vbauerster/mpb/v6/decor"
"github.com/vbauerster/mpb/v6/internal"
)
const (
rLeft = iota
rFill
rTip
rSpace
rRight
rRevTip
rRefill
)
// BarDefaultStyle is a style for rendering a progress bar.
// It consist of 7 ordered runes:
//
// '1st rune' stands for left boundary rune
//
// '2nd rune' stands for fill rune
//
// '3rd rune' stands for tip rune
//
// '4th rune' stands for space rune
//
// '5th rune' stands for right boundary rune
//
// '6th rune' stands for reverse tip rune
//
// '7th rune' stands for refill rune
//
const BarDefaultStyle string = "[=>-]<+"
type barFiller struct {
format [][]byte
rwidth []int
tip []byte
refill int64
reverse bool
flush func(io.Writer, *space, [][]byte)
}
type space struct {
space []byte
rwidth int
count int
}
// NewBarFiller returns a BarFiller implementation which renders a
// progress bar in regular direction. If style is empty string,
// BarDefaultStyle is applied. To be used with `*Progress.Add(...)
// *Bar` method.
func NewBarFiller(style string) BarFiller {
return newBarFiller(style, false)
}
// NewBarFillerRev returns a BarFiller implementation which renders a
// progress bar in reverse direction. If style is empty string,
// BarDefaultStyle is applied. To be used with `*Progress.Add(...)
// *Bar` method.
func NewBarFillerRev(style string) BarFiller {
return newBarFiller(style, true)
}
// NewBarFillerPick pick between regular and reverse BarFiller implementation
// based on rev param. To be used with `*Progress.Add(...) *Bar` method.
func NewBarFillerPick(style string, rev bool) BarFiller {
return newBarFiller(style, rev)
}
func newBarFiller(style string, rev bool) BarFiller {
bf := &barFiller{
format: make([][]byte, len(BarDefaultStyle)),
rwidth: make([]int, len(BarDefaultStyle)),
reverse: rev,
}
bf.parse(BarDefaultStyle)
if style != "" && style != BarDefaultStyle {
bf.parse(style)
}
return bf
}
func (s *barFiller) parse(style string) {
if !utf8.ValidString(style) {
panic("invalid bar style")
}
srcFormat := make([][]byte, len(BarDefaultStyle))
srcRwidth := make([]int, len(BarDefaultStyle))
i := 0
for gr := uniseg.NewGraphemes(style); i < len(BarDefaultStyle) && gr.Next(); i++ {
srcFormat[i] = gr.Bytes()
srcRwidth[i] = runewidth.StringWidth(gr.Str())
}
copy(s.format, srcFormat[:i])
copy(s.rwidth, srcRwidth[:i])
if s.reverse {
s.tip = s.format[rRevTip]
s.flush = reverseFlush
} else {
s.tip = s.format[rTip]
s.flush = regularFlush
}
}
func (s *barFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
width := internal.CheckRequestedWidth(reqWidth, stat.AvailableWidth)
brackets := s.rwidth[rLeft] + s.rwidth[rRight]
if width < brackets {
return
}
// don't count brackets as progress
width -= brackets
w.Write(s.format[rLeft])
defer w.Write(s.format[rRight])
cwidth := int(internal.PercentageRound(stat.Total, stat.Current, width))
space := &space{
space: s.format[rSpace],
rwidth: s.rwidth[rSpace],
count: width - cwidth,
}
index, refill := 0, 0
bb := make([][]byte, cwidth)
if cwidth > 0 && cwidth != width {
bb[index] = s.tip
cwidth -= s.rwidth[rTip]
index++
}
if stat.Refill > 0 {
refill = int(internal.PercentageRound(stat.Total, int64(stat.Refill), width))
if refill > cwidth {
refill = cwidth
}
cwidth -= refill
}
for cwidth > 0 {
bb[index] = s.format[rFill]
cwidth -= s.rwidth[rFill]
index++
}
for refill > 0 {
bb[index] = s.format[rRefill]
refill -= s.rwidth[rRefill]
index++
}
if cwidth+refill < 0 || space.rwidth > 1 {
buf := new(bytes.Buffer)
s.flush(buf, space, bb[:index])
io.WriteString(w, runewidth.Truncate(buf.String(), width, "…"))
return
}
s.flush(w, space, bb)
}
func regularFlush(w io.Writer, space *space, bb [][]byte) {
for i := len(bb) - 1; i >= 0; i-- {
w.Write(bb[i])
}
for space.count > 0 {
w.Write(space.space)
space.count -= space.rwidth
}
}
func reverseFlush(w io.Writer, space *space, bb [][]byte) {
for space.count > 0 {
w.Write(space.space)
space.count -= space.rwidth
}
for i := 0; i < len(bb); i++ {
w.Write(bb[i])
}
}

View File

@@ -1,65 +0,0 @@
package mpb
import (
"io"
"strings"
"github.com/mattn/go-runewidth"
"github.com/vbauerster/mpb/v6/decor"
"github.com/vbauerster/mpb/v6/internal"
)
// SpinnerAlignment enum.
type SpinnerAlignment int
// SpinnerAlignment kinds.
const (
SpinnerOnLeft SpinnerAlignment = iota
SpinnerOnMiddle
SpinnerOnRight
)
// SpinnerDefaultStyle is a style for rendering a spinner.
var SpinnerDefaultStyle = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
type spinnerFiller struct {
frames []string
count uint
alignment SpinnerAlignment
}
// NewSpinnerFiller returns a BarFiller implementation which renders
// a spinner. If style is nil or zero length, SpinnerDefaultStyle is
// applied. To be used with `*Progress.Add(...) *Bar` method.
func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller {
if len(style) == 0 {
style = SpinnerDefaultStyle
}
filler := &spinnerFiller{
frames: style,
alignment: alignment,
}
return filler
}
func (s *spinnerFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
width := internal.CheckRequestedWidth(reqWidth, stat.AvailableWidth)
frame := s.frames[s.count%uint(len(s.frames))]
frameWidth := runewidth.StringWidth(frame)
if width < frameWidth {
return
}
switch rest := width - frameWidth; s.alignment {
case SpinnerOnLeft:
io.WriteString(w, frame+strings.Repeat(" ", rest))
case SpinnerOnMiddle:
str := strings.Repeat(" ", rest/2) + frame + strings.Repeat(" ", rest/2+rest%2)
io.WriteString(w, str)
case SpinnerOnRight:
io.WriteString(w, strings.Repeat(" ", rest)+frame)
}
s.count++
}

View File

@@ -1,20 +0,0 @@
// Package decor provides common decorators for "github.com/vbauerster/mpb/v6" module.
/*
Some decorators returned by this package might have a closure state. It is ok to use
decorators concurrently, unless you share the same decorator among multiple
*mpb.Bar instances. To avoid data races, create new decorator per *mpb.Bar instance.
Don't:
p := mpb.New()
name := decor.Name("bar")
p.AddBar(100, mpb.AppendDecorators(name))
p.AddBar(100, mpb.AppendDecorators(name))
Do:
p := mpb.New()
p.AddBar(100, mpb.AppendDecorators(decor.Name("bar1")))
p.AddBar(100, mpb.AppendDecorators(decor.Name("bar2")))
*/
package decor

View File

@@ -1,11 +0,0 @@
module github.com/vbauerster/mpb/v6
require (
github.com/VividCortex/ewma v1.1.1
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/mattn/go-runewidth v0.0.10
github.com/rivo/uniseg v0.2.0
golang.org/x/sys v0.0.0-20210324051608-47abb6519492
)
go 1.14

View File

@@ -1,11 +0,0 @@
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

View File

@@ -1,8 +1,9 @@
# Multi Progress Bar
[![GoDoc](https://pkg.go.dev/badge/github.com/vbauerster/mpb)](https://pkg.go.dev/github.com/vbauerster/mpb/v6)
[![GoDoc](https://pkg.go.dev/badge/github.com/vbauerster/mpb)](https://pkg.go.dev/github.com/vbauerster/mpb/v7)
[![Build Status](https://travis-ci.org/vbauerster/mpb.svg?branch=master)](https://travis-ci.org/vbauerster/mpb)
[![Go Report Card](https://goreportcard.com/badge/github.com/vbauerster/mpb)](https://goreportcard.com/report/github.com/vbauerster/mpb)
[![Donate with PayPal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/vbauerster)
**mpb** is a Go lib for rendering progress bars in terminal applications.
@@ -26,8 +27,8 @@ import (
"math/rand"
"time"
"github.com/vbauerster/mpb/v6"
"github.com/vbauerster/mpb/v6/decor"
"github.com/vbauerster/mpb/v7"
"github.com/vbauerster/mpb/v7/decor"
)
func main() {
@@ -39,7 +40,7 @@ func main() {
// adding a single bar, which will inherit container's width
bar := p.Add(int64(total),
// progress bar filler with customized style
mpb.NewBarFiller("╢▌▌░╟"),
mpb.NewBarFiller(mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟")),
mpb.PrependDecorators(
// display our name with one space on the right
decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
@@ -65,7 +66,7 @@ func main() {
```go
var wg sync.WaitGroup
// pass &wg (optional), so p will wait for it eventually
// passed &wg will be accounted at p.Wait() call
p := mpb.New(mpb.WithWaitGroup(&wg))
total, numBars := 100, 3
wg.Add(numBars)

View File

@@ -12,7 +12,7 @@ import (
"github.com/acarl005/stripansi"
"github.com/mattn/go-runewidth"
"github.com/vbauerster/mpb/v6/decor"
"github.com/vbauerster/mpb/v7/decor"
)
// Bar represents a progress bar.
@@ -390,12 +390,6 @@ func (b *Bar) wSyncTable() [][]chan int {
}
func (s *bState) draw(stat decor.Statistics) io.Reader {
if !s.trimSpace {
stat.AvailableWidth -= 2
s.bufB.WriteByte(' ')
defer s.bufB.WriteByte(' ')
}
nlr := strings.NewReader("\n")
tw := stat.AvailableWidth
for _, d := range s.pDecorators {
@@ -403,10 +397,16 @@ func (s *bState) draw(stat decor.Statistics) io.Reader {
stat.AvailableWidth -= runewidth.StringWidth(stripansi.Strip(str))
s.bufP.WriteString(str)
}
if stat.AvailableWidth <= 0 {
if stat.AvailableWidth < 1 {
trunc := strings.NewReader(runewidth.Truncate(stripansi.Strip(s.bufP.String()), tw, "…"))
s.bufP.Reset()
return io.MultiReader(trunc, s.bufB, nlr)
return io.MultiReader(trunc, nlr)
}
if !s.trimSpace && stat.AvailableWidth > 1 {
stat.AvailableWidth -= 2
s.bufB.WriteByte(' ')
defer s.bufB.WriteByte(' ')
}
tw = stat.AvailableWidth
@@ -415,7 +415,7 @@ func (s *bState) draw(stat decor.Statistics) io.Reader {
stat.AvailableWidth -= runewidth.StringWidth(stripansi.Strip(str))
s.bufA.WriteString(str)
}
if stat.AvailableWidth <= 0 {
if stat.AvailableWidth < 1 {
trunc := strings.NewReader(runewidth.Truncate(stripansi.Strip(s.bufA.String()), tw, "…"))
s.bufA.Reset()
return io.MultiReader(s.bufP, s.bufB, trunc, nlr)

View File

@@ -3,7 +3,7 @@ package mpb
import (
"io"
"github.com/vbauerster/mpb/v6/decor"
"github.com/vbauerster/mpb/v7/decor"
)
// BarFiller interface.
@@ -14,18 +14,26 @@ import (
//
// Default implementations can be obtained via:
//
// func NewBarFiller(style string) BarFiller
// func NewBarFillerRev(style string) BarFiller
// func NewBarFillerPick(style string, rev bool) BarFiller
// func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller
// func NewBarFiller(BarStyle()) BarFiller
// func NewBarFiller(SpinnerStyle()) BarFiller
//
type BarFiller interface {
Fill(w io.Writer, reqWidth int, stat decor.Statistics)
}
// BarFillerBuilder interface.
type BarFillerBuilder interface {
Build() BarFiller
}
// BarFillerFunc is function type adapter to convert function into BarFiller.
type BarFillerFunc func(w io.Writer, reqWidth int, stat decor.Statistics)
func (f BarFillerFunc) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
f(w, reqWidth, stat)
}
// NewBarFiller constructs a BarFiller from provided BarFillerBuilder.
func NewBarFiller(b BarFillerBuilder) BarFiller {
return b.Build()
}

219
vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go generated vendored Normal file
View File

@@ -0,0 +1,219 @@
package mpb
import (
"io"
"github.com/acarl005/stripansi"
"github.com/mattn/go-runewidth"
"github.com/vbauerster/mpb/v7/decor"
"github.com/vbauerster/mpb/v7/internal"
)
const (
iLbound = iota
iRbound
iFiller
iRefiller
iPadding
components
)
// BarStyleComposer interface.
type BarStyleComposer interface {
BarFillerBuilder
Lbound(string) BarStyleComposer
Rbound(string) BarStyleComposer
Filler(string) BarStyleComposer
Refiller(string) BarStyleComposer
Padding(string) BarStyleComposer
Tip(...string) BarStyleComposer
Reverse() BarStyleComposer
}
type bFiller struct {
components [components]*component
tip struct {
count uint
frames []*component
}
flush func(dst io.Writer, filling, padding [][]byte)
}
type component struct {
width int
bytes []byte
}
type barStyle struct {
lbound string
rbound string
filler string
refiller string
padding string
tip []string
rev bool
}
// BarStyle constructs default bar style which can be altered via
// BarStyleComposer interface.
func BarStyle() BarStyleComposer {
return &barStyle{
lbound: "[",
rbound: "]",
filler: "=",
refiller: "+",
padding: "-",
tip: []string{">"},
}
}
func (s *barStyle) Lbound(bound string) BarStyleComposer {
s.lbound = bound
return s
}
func (s *barStyle) Rbound(bound string) BarStyleComposer {
s.rbound = bound
return s
}
func (s *barStyle) Filler(filler string) BarStyleComposer {
s.filler = filler
return s
}
func (s *barStyle) Refiller(refiller string) BarStyleComposer {
s.refiller = refiller
return s
}
func (s *barStyle) Padding(padding string) BarStyleComposer {
s.padding = padding
return s
}
func (s *barStyle) Tip(tip ...string) BarStyleComposer {
if len(tip) != 0 {
s.tip = append(s.tip[:0], tip...)
}
return s
}
func (s *barStyle) Reverse() BarStyleComposer {
s.rev = true
return s
}
func (s *barStyle) Build() BarFiller {
bf := new(bFiller)
if s.rev {
bf.flush = func(dst io.Writer, filling, padding [][]byte) {
flush(dst, padding, filling)
}
} else {
bf.flush = flush
}
bf.components[iLbound] = &component{
width: runewidth.StringWidth(stripansi.Strip(s.lbound)),
bytes: []byte(s.lbound),
}
bf.components[iRbound] = &component{
width: runewidth.StringWidth(stripansi.Strip(s.rbound)),
bytes: []byte(s.rbound),
}
bf.components[iFiller] = &component{
width: runewidth.StringWidth(stripansi.Strip(s.filler)),
bytes: []byte(s.filler),
}
bf.components[iRefiller] = &component{
width: runewidth.StringWidth(stripansi.Strip(s.refiller)),
bytes: []byte(s.refiller),
}
bf.components[iPadding] = &component{
width: runewidth.StringWidth(stripansi.Strip(s.padding)),
bytes: []byte(s.padding),
}
bf.tip.frames = make([]*component, len(s.tip))
for i, t := range s.tip {
bf.tip.frames[i] = &component{
width: runewidth.StringWidth(stripansi.Strip(t)),
bytes: []byte(t),
}
}
return bf
}
func (s *bFiller) Fill(w io.Writer, width int, stat decor.Statistics) {
width = internal.CheckRequestedWidth(width, stat.AvailableWidth)
brackets := s.components[iLbound].width + s.components[iRbound].width
if width < brackets {
return
}
// don't count brackets as progress
width -= brackets
w.Write(s.components[iLbound].bytes)
defer w.Write(s.components[iRbound].bytes)
curWidth := int(internal.PercentageRound(stat.Total, stat.Current, width))
refWidth, filled := 0, curWidth
filling := make([][]byte, 0, curWidth)
if curWidth > 0 && curWidth != width {
tipFrame := s.tip.frames[s.tip.count%uint(len(s.tip.frames))]
filling = append(filling, tipFrame.bytes)
curWidth -= tipFrame.width
s.tip.count++
}
if stat.Refill > 0 && curWidth > 0 {
refWidth = int(internal.PercentageRound(stat.Total, int64(stat.Refill), width))
if refWidth > curWidth {
refWidth = curWidth
}
curWidth -= refWidth
}
for curWidth > 0 && curWidth >= s.components[iFiller].width {
filling = append(filling, s.components[iFiller].bytes)
curWidth -= s.components[iFiller].width
if s.components[iFiller].width == 0 {
break
}
}
for refWidth > 0 && refWidth >= s.components[iRefiller].width {
filling = append(filling, s.components[iRefiller].bytes)
refWidth -= s.components[iRefiller].width
if s.components[iRefiller].width == 0 {
break
}
}
filled -= curWidth + refWidth
padWidth := width - filled
padding := make([][]byte, 0, padWidth)
for padWidth > 0 && padWidth >= s.components[iPadding].width {
padding = append(padding, s.components[iPadding].bytes)
padWidth -= s.components[iPadding].width
if s.components[iPadding].width == 0 {
break
}
}
for padWidth > 0 {
padding = append(padding, []byte("…"))
padWidth--
}
s.flush(w, filling, padding)
}
func flush(dst io.Writer, filling, padding [][]byte) {
for i := len(filling) - 1; i >= 0; i-- {
dst.Write(filling[i])
}
for i := 0; i < len(padding); i++ {
dst.Write(padding[i])
}
}

View File

@@ -0,0 +1,87 @@
package mpb
import (
"io"
"strings"
"github.com/acarl005/stripansi"
"github.com/mattn/go-runewidth"
"github.com/vbauerster/mpb/v7/decor"
"github.com/vbauerster/mpb/v7/internal"
)
const (
positionLeft = 1 + iota
positionRight
)
// SpinnerStyleComposer interface.
type SpinnerStyleComposer interface {
BarFillerBuilder
PositionLeft() SpinnerStyleComposer
PositionRight() SpinnerStyleComposer
}
type sFiller struct {
count uint
position uint
frames []string
}
type spinnerStyle struct {
position uint
frames []string
}
// SpinnerStyle constructs default spinner style which can be altered via
// SpinnerStyleComposer interface.
func SpinnerStyle(frames ...string) SpinnerStyleComposer {
ss := new(spinnerStyle)
if len(frames) != 0 {
ss.frames = append(ss.frames, frames...)
} else {
ss.frames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
}
return ss
}
func (s *spinnerStyle) PositionLeft() SpinnerStyleComposer {
s.position = positionLeft
return s
}
func (s *spinnerStyle) PositionRight() SpinnerStyleComposer {
s.position = positionRight
return s
}
func (s *spinnerStyle) Build() BarFiller {
sf := &sFiller{
position: s.position,
frames: s.frames,
}
return sf
}
func (s *sFiller) Fill(w io.Writer, width int, stat decor.Statistics) {
width = internal.CheckRequestedWidth(width, stat.AvailableWidth)
frame := s.frames[s.count%uint(len(s.frames))]
frameWidth := runewidth.StringWidth(stripansi.Strip(frame))
if width < frameWidth {
return
}
rest := width - frameWidth
switch s.position {
case positionLeft:
io.WriteString(w, frame+strings.Repeat(" ", rest))
case positionRight:
io.WriteString(w, strings.Repeat(" ", rest)+frame)
default:
str := strings.Repeat(" ", rest/2) + frame + strings.Repeat(" ", rest/2+rest%2)
io.WriteString(w, str)
}
s.count++
}

View File

@@ -4,8 +4,8 @@ import (
"bytes"
"io"
"github.com/vbauerster/mpb/v6/decor"
"github.com/vbauerster/mpb/v6/internal"
"github.com/vbauerster/mpb/v7/decor"
"github.com/vbauerster/mpb/v7/internal"
)
// BarOption is a func option to alter default behavior of a bar.

View File

@@ -6,7 +6,7 @@ import (
"sync"
"time"
"github.com/vbauerster/mpb/v6/internal"
"github.com/vbauerster/mpb/v7/internal"
)
// ContainerOption is a func option to alter default behavior of a bar

19
vendor/github.com/vbauerster/mpb/v7/decor/doc.go generated vendored Normal file
View File

@@ -0,0 +1,19 @@
// Package decor provides common decorators for "github.com/vbauerster/mpb/v7" module.
//
// Some decorators returned by this package might have a closure state. It is ok to use
// decorators concurrently, unless you share the same decorator among multiple
// *mpb.Bar instances. To avoid data races, create new decorator per *mpb.Bar instance.
//
// Don't:
//
// p := mpb.New()
// name := decor.Name("bar")
// p.AddBar(100, mpb.AppendDecorators(name))
// p.AddBar(100, mpb.AppendDecorators(name))
//
// Do:
//
// p := mpb.New()
// p.AddBar(100, mpb.AppendDecorators(decor.Name("bar1")))
// p.AddBar(100, mpb.AppendDecorators(decor.Name("bar2")))
package decor

View File

@@ -5,7 +5,7 @@ import (
"io"
"strconv"
"github.com/vbauerster/mpb/v6/internal"
"github.com/vbauerster/mpb/v7/internal"
)
type percentageType float64

10
vendor/github.com/vbauerster/mpb/v7/go.mod generated vendored Normal file
View File

@@ -0,0 +1,10 @@
module github.com/vbauerster/mpb/v7
require (
github.com/VividCortex/ewma v1.2.0
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/mattn/go-runewidth v0.0.13
golang.org/x/sys v0.0.0-20210603125802-9665404d3644
)
go 1.14

10
vendor/github.com/vbauerster/mpb/v7/go.sum generated vendored Normal file
View File

@@ -0,0 +1,10 @@
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
golang.org/x/sys v0.0.0-20210603125802-9665404d3644 h1:CA1DEQ4NdKphKeL70tvsWNdT5oFh1lOjihRcEDROi0I=
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@@ -3,7 +3,7 @@ package internal
// CheckRequestedWidth checks that requested width doesn't overflow
// available width
func CheckRequestedWidth(requested, available int) int {
if requested <= 0 || requested >= available {
if requested < 1 || requested >= available {
return available
}
return requested

View File

@@ -13,8 +13,8 @@ import (
"sync"
"time"
"github.com/vbauerster/mpb/v6/cwriter"
"github.com/vbauerster/mpb/v6/decor"
"github.com/vbauerster/mpb/v7/cwriter"
"github.com/vbauerster/mpb/v7/decor"
)
const (
@@ -100,16 +100,16 @@ func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
}
// AddBar creates a bar with default bar filler. Different filler can
// be choosen and applied via `*Progress.Add(...) *Bar` method.
// be chosen and applied via `*Progress.Add(...) *Bar` method.
func (p *Progress) AddBar(total int64, options ...BarOption) *Bar {
return p.Add(total, NewBarFiller(BarDefaultStyle), options...)
return p.Add(total, NewBarFiller(BarStyle()), options...)
}
// AddSpinner creates a bar with default spinner filler. Different
// filler can be choosen and applied via `*Progress.Add(...) *Bar`
// filler can be chosen and applied via `*Progress.Add(...) *Bar`
// method.
func (p *Progress) AddSpinner(total int64, alignment SpinnerAlignment, options ...BarOption) *Bar {
return p.Add(total, NewSpinnerFiller(SpinnerDefaultStyle, alignment), options...)
func (p *Progress) AddSpinner(total int64, options ...BarOption) *Bar {
return p.Add(total, NewBarFiller(SpinnerStyle()), options...)
}
// Add creates a bar which renders itself by provided filler.