MCPcopy Index your code
hub / github.com/ad4mx/spinoff

github.com/ad4mx/spinoff @v0.8.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.8.0 ↗ · + Follow
25 symbols 41 edges 7 files 17 documented · 68%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

spinoff

an easy to use, robust library for displaying spinners in the terminal

Version Downloads Docs License Actions

🔨 Install

Add as a dependency to your Cargo.toml:

[dependencies]
spinoff = "0.8.0"

⚡ Usage

use spinoff::{Spinner, spinners, Color};
use std::thread::sleep;
use std::time::Duration;

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

Update a spinner

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::from_secs(3));
spinner.update(Spinners::Dots2, "Retrying...", None);
sleep(Duration::from_secs(3));
spinner.stop()

Specify an output stream

use spinoff::{Spinner, spinners, Color, Streams};
use std::thread::sleep;
use std::time::Duration;

let mut spinner = Spinner::new_with_stream(spinners::Line, "Loading...", Color::Yellow, Streams::Stderr);
sleep(Duration::from_secs(3));
spinner.stop_and_persist("📜", "Task done.");

💫 Spinners

spinoff includes over 80+ spinner variants out of the box. All spinner variants are treated as features that can be enabled or disabled. By default, all of them are enabled for ease of use. To disable/enable variants, you will have to edit your cargo.toml file:

[dependencies]
spinoff = { version = "0.8.0", features = ["dots", "arc", "line"] }

Any suggestions for new spinner variants are welcome.

Creating your own spinner

You can create your own spinner using the spinner! macro:

use spinoff::*;
use std::thread::sleep;
use std::time::Duration;

let frames = spinner!([">", ">>", ">>>"], 100);
let mut sp = Spinner::new(frames, "Hello World!", None);
sleep(Duration::from_millis(800));
sp.stop();

❗Note for Windows Users

For colors to work properly, you need to add a few extra lines to your code:

use colored::control
control::enable_virtual_terminal(true).unwrap();

📖 Documentation

⚙ Examples

cargo run --example simple
cargo run --example stream
cargo run --example stop_and_persist

Other examples can be found in the documentation.

🚧 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.

Core symbols most depended-on inside this repo

stop_spinner_thread
called by 11
src/lib.rs
delete_last_line
called by 2
src/utils.rs
success
called by 2
src/lib.rs
stop_and_persist
called by 1
src/lib.rs
get_stream
called by 1
src/streams.rs
colorize
called by 0
src/utils.rs
new
called by 0
src/lib.rs
new_with_stream
called by 0
src/lib.rs

Shape

Method 16
Function 5
Class 2
Enum 2

Languages

Rust100%

Modules by API surface

src/lib.rs15 symbols
src/utils.rs3 symbols
src/streams.rs3 symbols
src/spinners.rs1 symbols
examples/stream.rs1 symbols
examples/stop_and_persist.rs1 symbols
examples/simple.rs1 symbols

For agents

$ claude mcp add spinoff \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact