diff --git a/src/pkg/message/progress.go b/src/pkg/message/progress.go index 7c050b0ba2..c5e1a5c4db 100644 --- a/src/pkg/message/progress.go +++ b/src/pkg/message/progress.go @@ -6,6 +6,7 @@ package message import ( "fmt" + "log/slog" "os" "github.com/pterm/pterm" @@ -22,10 +23,11 @@ type ProgressBar struct { // NewProgressBar creates a new ProgressBar instance from a total value and a format. func NewProgressBar(total int64, text string) *ProgressBar { var progress *pterm.ProgressbarPrinter + var err error if NoProgress { Info(text) } else { - progress, _ = pterm.DefaultProgressbar. + progress, err = pterm.DefaultProgressbar. WithTotal(int(total)). WithShowCount(false). WithTitle(padding + text). @@ -33,6 +35,9 @@ func NewProgressBar(total int64, text string) *ProgressBar { WithMaxWidth(TermWidth). WithWriter(os.Stderr). Start() + if err != nil { + slog.Debug("Unable to create default progressbar", "error", err) + } } return &ProgressBar{ @@ -53,7 +58,10 @@ func (p *ProgressBar) Updatef(format string, a ...any) { // Failf marks the ProgressBar as failed in the CLI. func (p *ProgressBar) Failf(format string, a ...any) { - p.Close() + err := p.Close() + if err != nil { + slog.Debug("unable to close failed progressbar", "error", err) + } Warnf(format, a...) } @@ -103,7 +111,10 @@ func (p *ProgressBar) Write(data []byte) (int, error) { // Successf marks the ProgressBar as successful in the CLI. func (p *ProgressBar) Successf(format string, a ...any) { - p.Close() + err := p.Close() + if err != nil { + slog.Debug("unable to close successful progressbar", "error", err) + } pterm.Success.Printfln(format, a...) } diff --git a/src/pkg/message/spinner.go b/src/pkg/message/spinner.go index 93511a705c..76d2d81bb5 100644 --- a/src/pkg/message/spinner.go +++ b/src/pkg/message/spinner.go @@ -8,6 +8,7 @@ import ( "bufio" "bytes" "fmt" + "log/slog" "strings" "github.com/pterm/pterm" @@ -34,15 +35,19 @@ func NewProgressSpinner(format string, a ...any) *Spinner { } var spinner *pterm.SpinnerPrinter + var err error text := pterm.Sprintf(format, a...) if NoProgress { Info(text) } else { - spinner, _ = pterm.DefaultSpinner. + spinner, err = pterm.DefaultSpinner. WithRemoveWhenDone(false). // Src: https://github.com/gernest/wow/blob/master/spin/spinners.go#L335 WithSequence(sequence...). Start(text) + if err != nil { + slog.Debug("unable to create default spinner", "error", err) + } } activeSpinner = &Spinner{ @@ -108,7 +113,10 @@ func (p *Spinner) Updatef(format string, a ...any) { // Stop the spinner. func (p *Spinner) Stop() { if p.spinner != nil && p.spinner.IsActive { - _ = p.spinner.Stop() + err := p.spinner.Stop() + if err != nil { + slog.Debug("unable to stop spinner", "error", err) + } } activeSpinner = nil }