Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(spinner_printer): make spinner stop return itself #566

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions spinner_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ func (s SpinnerPrinter) Start(text ...interface{}) (*SpinnerPrinter, error) {

// Stop terminates the SpinnerPrinter immediately.
// The SpinnerPrinter will not resolve into anything.
func (s *SpinnerPrinter) Stop() error {
func (s *SpinnerPrinter) Stop() (*SpinnerPrinter, error) {
if !s.IsActive {
return nil
return s, nil
}
s.IsActive = false
if s.RemoveWhenDone {
Expand All @@ -177,7 +177,7 @@ func (s *SpinnerPrinter) Stop() error {
} else {
Fprintln(s.Writer)
}
return nil
return s, nil
}

// GenericStart runs Start, but returns a LivePrinter.
Expand All @@ -193,8 +193,8 @@ func (s *SpinnerPrinter) GenericStart() (*LivePrinter, error) {
// This is used for the interface LivePrinter.
// You most likely want to use Stop instead of this in your program.
func (s *SpinnerPrinter) GenericStop() (*LivePrinter, error) {
_ = s.Stop()
lp := LivePrinter(s)
s2, _ := s.Stop()
lp := LivePrinter(s2)
return &lp, nil
}

Expand All @@ -210,7 +210,7 @@ func (s *SpinnerPrinter) Info(message ...interface{}) {
}
fClearLine(s.Writer)
Fprinto(s.Writer, s.InfoPrinter.Sprint(message...))
_ = s.Stop()
s.Stop()
}

// Success displays the success printer.
Expand All @@ -225,7 +225,7 @@ func (s *SpinnerPrinter) Success(message ...interface{}) {
}
fClearLine(s.Writer)
Fprinto(s.Writer, s.SuccessPrinter.Sprint(message...))
_ = s.Stop()
s.Stop()
}

// Fail displays the fail printer.
Expand All @@ -240,7 +240,7 @@ func (s *SpinnerPrinter) Fail(message ...interface{}) {
}
fClearLine(s.Writer)
Fprinto(s.Writer, s.FailPrinter.Sprint(message...))
_ = s.Stop()
s.Stop()
}

// Warning displays the warning printer.
Expand All @@ -255,5 +255,5 @@ func (s *SpinnerPrinter) Warning(message ...interface{}) {
}
fClearLine(s.Writer)
Fprinto(s.Writer, s.WarningPrinter.Sprint(message...))
_ = s.Stop()
s.Stop()
}