🥬 spinach
Practical spinner for Rust —
v3now with method chaining
Install
Add as a dependency to your Cargo.toml.
[]
= "3"
Usage
Basic example.
use Spinner;
Starting
use ;
// With custom text
let s = new.start;
// With custom text, spinner, spinner speed and spinner color
let symbols = vec!;
let s = new
.color
.symbols
.frames_duration
.start;
Updating
use ;
let s = new.start;
// Updating text
s.text.update;
// Updating color
s.color.update;
// Updating spinner symbols
s.symbols.update;
// Updating spinner speed
s.frames_duration.update;
// Updating multiple at once
s.text.color;
Stopping
use ;
let s = new.start;
// Stop with final `✔` frame and green color.
s.text.success;
// Stop with final `✖` frame and red color.
s.text.failure;
// Stop with final `⚠` frame and yellow color.
s.text.warn;
// Stop with final `ℹ` frame and blue color.
s.text.stop;
// Stop current spinner (sends update at the same time)
s.stop; // freeze
s.text.symbols.stop; // stop with the text "spinach'd" and a vegetable as the spinner
FAQ
How to avoid leaving terminal without prompt on interupt (ctrl^c)?
You can use a library like ctrlc to handle interupts.
The most basic way to handle it would be in conjuction with this lib QoL show_cursor function like this:
use ;
Related
Inspired by: