From a13221f47e5ed8b2f3a491dfa4227402731a6eb3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 06:22:25 +0000 Subject: [PATCH] Bump github.com/schollz/progressbar/v3 from 3.14.5 to 3.14.6 Bumps [github.com/schollz/progressbar/v3](https://github.com/schollz/progressbar) from 3.14.5 to 3.14.6. - [Release notes](https://github.com/schollz/progressbar/releases) - [Commits](https://github.com/schollz/progressbar/compare/v3.14.5...v3.14.6) --- updated-dependencies: - dependency-name: github.com/schollz/progressbar/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +-- .../schollz/progressbar/v3/progressbar.go | 25 +++++++++++++++++++ vendor/modules.txt | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index abf58ef29..c86e9165b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/google/go-containerregistry v0.20.1 github.com/onsi/gomega v1.34.1 github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 - github.com/schollz/progressbar/v3 v3.14.5 + github.com/schollz/progressbar/v3 v3.14.6 github.com/shipwright-io/build v0.13.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index f89cb388f..a9f8ba5b1 100644 --- a/go.sum +++ b/go.sum @@ -379,8 +379,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs= -github.com/schollz/progressbar/v3 v3.14.5 h1:97RrSxbBASxQuZN9yemnyGrFZ/swnG6IrEe2R0BseX8= -github.com/schollz/progressbar/v3 v3.14.5/go.mod h1:Nrzpuw3Nl0srLY0VlTvC4V6RL50pcEymjy6qyJAaLa0= +github.com/schollz/progressbar/v3 v3.14.6 h1:GyjwcWBAf+GFDMLziwerKvpuS7ZF+mNTAXIB2aspiZs= +github.com/schollz/progressbar/v3 v3.14.6/go.mod h1:Nrzpuw3Nl0srLY0VlTvC4V6RL50pcEymjy6qyJAaLa0= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shipwright-io/build v0.13.0 h1:UBap+Mk6P0fji/sLc3eBmDlAPWvZWE4KdSQiVUkwYEU= diff --git a/vendor/github.com/schollz/progressbar/v3/progressbar.go b/vendor/github.com/schollz/progressbar/v3/progressbar.go index e3bd67b31..56c147e81 100644 --- a/vendor/github.com/schollz/progressbar/v3/progressbar.go +++ b/vendor/github.com/schollz/progressbar/v3/progressbar.go @@ -1,6 +1,7 @@ package progressbar import ( + "bytes" "errors" "fmt" "io" @@ -121,6 +122,8 @@ type config struct { // showDescriptionAtLineEnd specifies whether description should be written at line end instead of line start showDescriptionAtLineEnd bool + + stdBuffer bytes.Buffer } // Theme defines the elements of the bar @@ -689,6 +692,7 @@ func (p *ProgressBar) render() error { if !p.state.finished && p.state.currentNum >= p.config.max { p.state.finished = true if !p.config.clearOnFinish { + io.Copy(p.config.writer, &p.config.stdBuffer) renderProgressBar(p.config, &p.state) } if p.config.onCompletion != nil { @@ -707,6 +711,7 @@ func (p *ProgressBar) render() error { } // then, re-render the current progress bar + io.Copy(p.config.writer, &p.config.stdBuffer) w, err := renderProgressBar(p.config, &p.state) if err != nil { return err @@ -1142,3 +1147,23 @@ var termWidth = func() (width int, err error) { return 0, err } + +func shouldCacheOutput(pb *ProgressBar) bool { + return !pb.state.finished && !pb.state.exit && !pb.config.invisible +} + +func Bprintln(pb *ProgressBar, a ...interface{}) (int, error) { + if !shouldCacheOutput(pb) { + return fmt.Fprintln(pb.config.writer, a...) + } else { + return fmt.Fprintln(&pb.config.stdBuffer, a...) + } +} + +func Bprintf(pb *ProgressBar, format string, a ...interface{}) (int, error) { + if !shouldCacheOutput(pb) { + return fmt.Fprintf(pb.config.writer, format, a...) + } else { + return fmt.Fprintf(&pb.config.stdBuffer, format, a...) + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index c04870f1f..90936c703 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -314,7 +314,7 @@ github.com/russross/blackfriday/v2 # github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 ## explicit; go 1.13 github.com/sabhiram/go-gitignore -# github.com/schollz/progressbar/v3 v3.14.5 +# github.com/schollz/progressbar/v3 v3.14.6 ## explicit; go 1.13 github.com/schollz/progressbar/v3 # github.com/shipwright-io/build v0.13.0