spinoff

simple library for displaying spinners in the terminal

Version Downloads Docs License Actions

πŸ”¨ Install

Add as a dependency to your Cargo.toml:

toml [dependencies] spinoff = "0.6.0"

⚑ Usage

```rust use spinoff::{Spinner, Spinners, Color}; use std::thread::sleep; use std::time::Duration;

let spinner = Spinner::new(Spinners::Dots, "Loading...", Color::Blue); sleep(Duration::from_secs(3)); spinner.success("Done!"); ```

Update a spinner

```rust use spinoff::{Spinner, Spinners, Color}; use std::thread::sleep; use std::time::Duration;

let mut spinner = Spinner::new(Spinners::Aesthetic, "Loading...", Color::Red); sleep(Duration::fromsecs(3)); spinner.update(Spinners::Dots2, "Retrying...", None); sleep(Duration::fromsecs(3)); spinner.stop() ```

Stop a spinner and persist a symbol and message

```rust use spinoff::{Spinner, Spinners, Color}; use std::thread::sleep; use std::time::Duration;

let spinner = Spinner::new(Spinners::Arc, "Loading...", Color::Green); sleep(Duration::fromsecs(3)); spinner.stopand_persist("πŸ“œ", "Task done."); ```

Specify an output stream

```rust use spinoff::{Spinner, Spinners, Color, Streams}; use std::thread::sleep; use std::time::Duration;

let spinner = Spinner::newwithstream(Spinners::Line, "Loading...", Color::Yellow, Streams::Stderr); sleep(Duration::fromsecs(3)); spinner.stopand_persist("πŸ“œ", "Task done."); ```

❗Note for Windows Users

For colors to work properly, you need to add a few extra lines to your code: rust use colored::control control::enable_virtual_terminal(true).unwrap();

Other examples can be found in the documentation.

πŸ“– Documentation

βš™ Examples

To run some of the included examples, use: bash cargo run --example all_spinners

bash cargo run --example simple

🚧 Contributing

Any contributions to this crate are highly appreciated. If you have any ideas/suggestions/bug fixes, please open an issue or a pull request. If you like the project, star this project on GitHub.

πŸ“‘ License

This crate is licensed under the MIT license.