🥬 spinach
Practical spinner for Rust
Install
Add as a dependency to your Cargo.toml.
[]
= "2"
Usage
Basic example.
use sleep;
use Duration;
use Spinach;
Creating
use ;
// Using defaults + custom text
let s = new;
// Using custom spinner
let spinner = new;
let s = new_with);
// Also with partial config (fallback to defaults)
let s = new_with;
Updating
use ;
let s = new;
// Updating text
s.text;
// Updating color
s.color;
// Updating multiple
s.update_with;
// Also with partial update (keep current)
s.update_with;
Stopping
use ;
let s = new;
// Stop with final `✔` frame, green color and optional text change.
s.success;
// Stop with final `✖` frame, red color and optional text change.
s.fail;
// Stop with final `âš ` frame, yellow color and optional text change.
s.warn;
// Stop with final `ℹ` frame, blue color and optional text change.
s.info;
// Stop current spinner (freeze the frame)
s.stop;
// Stopping with custom final frame, text and color
s.stop_with;
// Also with partial update (keep current)
s.stop_with;
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: