Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ad4mx/spinoff
π« Easy to use, robust Rust library for displaying spinners in the terminal
https://github.com/ad4mx/spinoff
cli command-line command-line-tool spinner terminal
Last synced: 14 days ago
JSON representation
π« Easy to use, robust Rust library for displaying spinners in the terminal
- Host: GitHub
- URL: https://github.com/ad4mx/spinoff
- Owner: ad4mx
- License: mit
- Created: 2022-07-15T18:00:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T20:51:26.000Z (11 months ago)
- Last Synced: 2024-10-07T19:07:40.077Z (about 1 month ago)
- Topics: cli, command-line, command-line-tool, spinner, terminal
- Language: Rust
- Homepage:
- Size: 1.37 MB
- Stars: 551
- Watchers: 5
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# spinoff
> an easy to use, robust library for displaying spinners in the terminal[![Version](https://img.shields.io/crates/v/spinoff.svg)](https://crates.io/crates/spinoff) [![Downloads](https://img.shields.io/crates/d/spinoff)](https://crates.io/crates/spinoff) [![Docs](https://img.shields.io/docsrs/spinoff)](https://docs.rs/spinoff/latest/spinoff) [![License](https://img.shields.io/crates/l/spinoff)](https://crates.io/crates/spinoff) ![Actions](https://img.shields.io/github/actions/workflow/status/ad4mx/spinoff/rust.yml?branch=main)
![](assets/index.gif)
## π¨ Install
Add as a dependency to your `Cargo.toml`:```toml
[dependencies]
spinoff = "0.8.0"
```## β‘ Usage
```rust
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
```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::from_secs(3));
spinner.update(spinners::Dots2, "Retrying...", None);
sleep(Duration::from_secs(3));
spinner.stop()
```### Specify an output stream
```rust
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:```toml
[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:```rust
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:
```rust
use colored::control
control::set_virtual_terminal(true).unwrap();
```## π Documentation
* All relevant documentation can be found on the [Docs.rs page](https://docs.rs/spinoff/latest/spinoff/).
* If you want to see all the available `spinner` options, refer to [the `spinner` module](https://docs.rs/spinoff/0.7.0/spinoff/spinners/index.html).## β Examples
```bash
cargo run --example simple
```
```bash
cargo run --example stream
```
```bash
cargo run --example stop_and_persist
```
Other examples can be found in the [documentation](https://docs.rs/spinoff/latest/spinoff/).
## π§ ContributingAny contributions to this crate are highly appreciated. If you have any ideas/suggestions/bug fixes, please open an [issue](https://github.com/ad4mx/spinoff/issues) or a [pull request](https://github.com/ad4mx/spinoff/pulls).
If you like the project, [star this project on GitHub.](https://github.com/ad4mx/spinoff)## π License
This crate is licensed under the [MIT license](LICENSE).