diff --git a/go.mod b/go.mod index 2f3b23de3..a0809fc23 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( github.com/shirou/gopsutil/v3 v3.24.5 github.com/stretchr/testify v1.10.0 github.com/urfave/cli/v2 v2.27.6 - github.com/vbauerster/mpb/v8 v8.9.3 + github.com/vbauerster/mpb/v8 v8.10.0 github.com/vishvananda/netlink v1.3.0 go.githedgehog.com/fabric v0.73.0 go.githedgehog.com/gateway v0.4.1 diff --git a/go.sum b/go.sum index cdb5f2a55..ddffc8d28 100644 --- a/go.sum +++ b/go.sum @@ -862,8 +862,8 @@ github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/vbatts/tar-split v0.11.6 h1:4SjTW5+PU11n6fZenf2IPoV8/tz3AaYHMWjf23envGs= github.com/vbatts/tar-split v0.11.6/go.mod h1:dqKNtesIOr2j2Qv3W/cHjnvk9I8+G7oAkFDFN6TCBEI= -github.com/vbauerster/mpb/v8 v8.9.3 h1:PnMeF+sMvYv9u23l6DO6Q3+Mdj408mjLRXIzmUmU2Z8= -github.com/vbauerster/mpb/v8 v8.9.3/go.mod h1:hxS8Hz4C6ijnppDSIX6LjG8FYJSoPo9iIOcE53Zik0c= +github.com/vbauerster/mpb/v8 v8.10.0 h1:5ZYEWM4ovaZGAibjzW4PlQNb5k+JpzMqVwgNyk+K0M8= +github.com/vbauerster/mpb/v8 v8.10.0/go.mod h1:DYPFebxSahB+f7tuEUGauLQ7w8ij3wMr4clsVuJCV4I= github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI= github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk= diff --git a/vendor/github.com/vbauerster/mpb/v8/bar_filler_bar.go b/vendor/github.com/vbauerster/mpb/v8/bar_filler_bar.go index 7a036d987..0075c18a8 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar_filler_bar.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar_filler_bar.go @@ -15,10 +15,10 @@ const ( iFiller iTip iPadding - components + iLen ) -var defaultBarStyle = [components]string{"[", "]", "+", "=", ">", "-"} +var defaultBarStyle = [iLen]string{"[", "]", "+", "=", ">", "-"} // BarStyleComposer interface. type BarStyleComposer interface { @@ -44,15 +44,17 @@ type component struct { bytes []byte } -type flushSection struct { - meta func(io.Writer, []byte) error +type barSection struct { + meta func(string) string bytes []byte } -type bFiller struct { - components [components]component - meta [components]func(io.Writer, []byte) error - flush func(io.Writer, ...flushSection) error +type barSections [iLen]barSection + +type barFiller struct { + components [iLen]component + metas [iLen]func(string) string + flushOp func(barSections, io.Writer) error tip struct { onComplete bool count uint @@ -61,8 +63,8 @@ type bFiller struct { } type barStyle struct { - style [components]string - metaFuncs [components]func(io.Writer, []byte) error + style [iLen]string + metas [iLen]func(string) string tipFrames []string tipOnComplete bool rev bool @@ -75,9 +77,6 @@ func BarStyle() BarStyleComposer { style: defaultBarStyle, tipFrames: []string{defaultBarStyle[iTip]}, } - for i := range bs.metaFuncs { - bs.metaFuncs[i] = defaultMeta - } return bs } @@ -87,7 +86,9 @@ func (s barStyle) Lbound(bound string) BarStyleComposer { } func (s barStyle) LboundMeta(fn func(string) string) BarStyleComposer { - s.metaFuncs[iLbound] = makeMetaFunc(fn) + if fn != nil && len(fn("")) != 0 { + s.metas[iLbound] = fn + } return s } @@ -97,7 +98,9 @@ func (s barStyle) Rbound(bound string) BarStyleComposer { } func (s barStyle) RboundMeta(fn func(string) string) BarStyleComposer { - s.metaFuncs[iRbound] = makeMetaFunc(fn) + if fn != nil && len(fn("")) != 0 { + s.metas[iRbound] = fn + } return s } @@ -107,7 +110,9 @@ func (s barStyle) Filler(filler string) BarStyleComposer { } func (s barStyle) FillerMeta(fn func(string) string) BarStyleComposer { - s.metaFuncs[iFiller] = makeMetaFunc(fn) + if fn != nil && len(fn("")) != 0 { + s.metas[iFiller] = fn + } return s } @@ -117,7 +122,9 @@ func (s barStyle) Refiller(refiller string) BarStyleComposer { } func (s barStyle) RefillerMeta(fn func(string) string) BarStyleComposer { - s.metaFuncs[iRefiller] = makeMetaFunc(fn) + if fn != nil && len(fn("")) != 0 { + s.metas[iRefiller] = fn + } return s } @@ -127,7 +134,9 @@ func (s barStyle) Padding(padding string) BarStyleComposer { } func (s barStyle) PaddingMeta(fn func(string) string) BarStyleComposer { - s.metaFuncs[iPadding] = makeMetaFunc(fn) + if fn != nil && len(fn("")) != 0 { + s.metas[iPadding] = fn + } return s } @@ -139,7 +148,9 @@ func (s barStyle) Tip(frames ...string) BarStyleComposer { } func (s barStyle) TipMeta(fn func(string) string) BarStyleComposer { - s.metaFuncs[iTip] = makeMetaFunc(fn) + if fn != nil && len(fn("")) != 0 { + s.metas[iTip] = fn + } return s } @@ -154,9 +165,7 @@ func (s barStyle) Reverse() BarStyleComposer { } func (s barStyle) Build() BarFiller { - bf := &bFiller{ - meta: s.metaFuncs, - } + bf := &barFiller{metas: s.metas} bf.components[iLbound] = component{ width: runewidth.StringWidth(s.style[iLbound]), bytes: []byte(s.style[iLbound]), @@ -186,34 +195,14 @@ func (s barStyle) Build() BarFiller { } } if s.rev { - bf.flush = func(w io.Writer, sections ...flushSection) error { - for i := len(sections) - 1; i >= 0; i-- { - if s := sections[i]; len(s.bytes) != 0 { - err := s.meta(w, s.bytes) - if err != nil { - return err - } - } - } - return nil - } + bf.flushOp = barSections.flushRev } else { - bf.flush = func(w io.Writer, sections ...flushSection) error { - for _, s := range sections { - if len(s.bytes) != 0 { - err := s.meta(w, s.bytes) - if err != nil { - return err - } - } - } - return nil - } + bf.flushOp = barSections.flush } return bf } -func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) error { +func (s *barFiller) Fill(w io.Writer, stat decor.Statistics) error { width := internal.CheckRequestedWidth(stat.RequestedWidth, stat.AvailableWidth) // don't count brackets as progress width -= (s.components[iLbound].width + s.components[iRbound].width) @@ -221,15 +210,6 @@ func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) error { return nil } - err := s.meta[iLbound](w, s.components[iLbound].bytes) - if err != nil { - return err - } - - if width == 0 { - return s.meta[iRbound](w, s.components[iRbound].bytes) - } - var tip component var refilling, filling, padding []byte var fillCount int @@ -265,26 +245,50 @@ func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) error { padding = append(padding, "…"...) } - err = s.flush(w, - flushSection{s.meta[iRefiller], refilling}, - flushSection{s.meta[iFiller], filling}, - flushSection{s.meta[iTip], tip.bytes}, - flushSection{s.meta[iPadding], padding}, - ) - if err != nil { - return err + return s.flushOp(barSections{ + {s.metas[iLbound], s.components[iLbound].bytes}, + {s.metas[iRbound], s.components[iRbound].bytes}, + {s.metas[iRefiller], refilling}, + {s.metas[iFiller], filling}, + {s.metas[iTip], tip.bytes}, + {s.metas[iPadding], padding}, + }, w) +} + +func (s barSection) flush(w io.Writer) (err error) { + if s.meta != nil { + _, err = io.WriteString(w, s.meta(string(s.bytes))) + } else { + _, err = w.Write(s.bytes) } - return s.meta[iRbound](w, s.components[iRbound].bytes) + return err } -func makeMetaFunc(fn func(string) string) func(io.Writer, []byte) error { - return func(w io.Writer, p []byte) (err error) { - _, err = io.WriteString(w, fn(string(p))) +func (bb barSections) flush(w io.Writer) error { + err := bb[0].flush(w) + if err != nil { return err } + for _, s := range bb[2:] { + err := s.flush(w) + if err != nil { + return err + } + } + return bb[1].flush(w) } -func defaultMeta(w io.Writer, p []byte) (err error) { - _, err = w.Write(p) - return err +func (bb barSections) flushRev(w io.Writer) error { + err := bb[0].flush(w) + if err != nil { + return err + } + ss := bb[2:] + for i := len(ss) - 1; i >= 0; i-- { + err := ss[i].flush(w) + if err != nil { + return err + } + } + return bb[1].flush(w) } diff --git a/vendor/github.com/vbauerster/mpb/v8/bar_filler_spinner.go b/vendor/github.com/vbauerster/mpb/v8/bar_filler_spinner.go index c9fd463eb..d89de94ce 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar_filler_spinner.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar_filler_spinner.go @@ -24,7 +24,7 @@ type SpinnerStyleComposer interface { Meta(func(string) string) SpinnerStyleComposer } -type sFiller struct { +type spinnerFiller struct { frames []string count uint meta func(string) string @@ -40,9 +40,7 @@ type spinnerStyle struct { // SpinnerStyle constructs default spinner style which can be altered via // SpinnerStyleComposer interface. func SpinnerStyle(frames ...string) SpinnerStyleComposer { - ss := spinnerStyle{ - meta: func(s string) string { return s }, - } + ss := spinnerStyle{meta: func(s string) string { return s }} if len(frames) != 0 { ss.frames = frames } else { @@ -62,12 +60,14 @@ func (s spinnerStyle) PositionRight() SpinnerStyleComposer { } func (s spinnerStyle) Meta(fn func(string) string) SpinnerStyleComposer { - s.meta = fn + if fn != nil && len(fn("")) != 0 { + s.meta = fn + } return s } func (s spinnerStyle) Build() BarFiller { - sf := &sFiller{ + sf := &spinnerFiller{ frames: s.frames, meta: s.meta, } @@ -88,7 +88,7 @@ func (s spinnerStyle) Build() BarFiller { return sf } -func (s *sFiller) Fill(w io.Writer, stat decor.Statistics) error { +func (s *spinnerFiller) Fill(w io.Writer, stat decor.Statistics) error { width := internal.CheckRequestedWidth(stat.RequestedWidth, stat.AvailableWidth) frame := s.frames[s.count%uint(len(s.frames))] frameWidth := runewidth.StringWidth(frame) diff --git a/vendor/github.com/vbauerster/mpb/v8/bar_option.go b/vendor/github.com/vbauerster/mpb/v8/bar_option.go index b586f6944..6c1b7e6f1 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar_option.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar_option.go @@ -86,6 +86,25 @@ func BarFillerOnComplete(message string) BarOption { }) } +// BarFillerClearOnAbort clears bar's filler on abort event. +// It's shortcut for BarFillerOnAbort(""). +func BarFillerClearOnAbort() BarOption { + return BarFillerOnAbort("") +} + +// BarFillerOnAbort replaces bar's filler with message, on abort event. +func BarFillerOnAbort(message string) BarOption { + return BarFillerMiddleware(func(base BarFiller) BarFiller { + return BarFillerFunc(func(w io.Writer, st decor.Statistics) error { + if st.Aborted { + _, err := io.WriteString(w, message) + return err + } + return base.Fill(w, st) + }) + }) +} + // BarFillerMiddleware provides a way to augment the underlying BarFiller. func BarFillerMiddleware(middle func(BarFiller) BarFiller) BarOption { if middle == nil { diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/size_type.go b/vendor/github.com/vbauerster/mpb/v8/decor/size_type.go index 00d11c218..90ecda688 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/size_type.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/size_type.go @@ -1,3 +1,6 @@ +//go:generate go tool stringer -type=SizeB1024 -trimprefix=_i +//go:generate go tool stringer -type=SizeB1000 -trimprefix=_ + package decor import ( @@ -5,9 +8,6 @@ import ( "strconv" ) -//go:generate stringer -type=SizeB1024 -trimprefix=_i -//go:generate stringer -type=SizeB1000 -trimprefix=_ - var ( _ fmt.Formatter = SizeB1024(0) _ fmt.Stringer = SizeB1024(0) diff --git a/vendor/modules.txt b/vendor/modules.txt index 3e08d4bdd..16b7774ee 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1646,8 +1646,8 @@ github.com/urfave/cli/v2 github.com/vbatts/tar-split/archive/tar github.com/vbatts/tar-split/tar/asm github.com/vbatts/tar-split/tar/storage -# github.com/vbauerster/mpb/v8 v8.9.3 -## explicit; go 1.17 +# github.com/vbauerster/mpb/v8 v8.10.0 +## explicit; go 1.23.0 github.com/vbauerster/mpb/v8 github.com/vbauerster/mpb/v8/cwriter github.com/vbauerster/mpb/v8/decor