ryn1x / Terminal-Spinners

Simple spinners and progress bars for Raku.
Artistic License 2.0
6 stars 2 forks source link

Wishlist: option to not print newline when spinner is done #6

Closed zerodogg closed 3 years ago

zerodogg commented 3 years ago

I've got an app that's printing "Working ... " followed by a spinner. When the operation is done, I want to replace the spinner with the word "done". Right now I've got to resort to ansi escape sequences to go back one line, and then reprint the whole string. Having an option to not print a newline when done in .await would be useful.

ryn1x commented 3 years ago

Hmm good point. .await is a little bit less flexible. I would be happy to merge a pull request if you want to add another adverb. For now another option is the slightly more verbose usage by calling .next.

Something along these lines:

use Terminal::Spinners;

my $spinner = Spinner.new: type => 'three-dots2';
my $promise = start sleep 3;
print "Working    ";
until $promise.status {
    $spinner.next;
}
say "\b\b\bdone";