2022-07-15 12:59:22 -05:00
|
|
|
# spinoff
|
|
|
|
`spinoff` is a simple to use library for displaying spinners in the terminal, with plenty of features and options.
|
|
|
|
|
2022-07-18 11:02:14 -05:00
|
|
|
[![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/workflow/status/ad4mx/spinoff/Rust)
|
2022-07-15 12:59:22 -05:00
|
|
|
|
2022-07-16 10:06:11 -05:00
|
|
|
|
2022-07-19 12:18:48 -05:00
|
|
|
![](assets/index.gif)
|
2022-07-16 08:58:14 -05:00
|
|
|
|
2022-07-18 09:36:10 -05:00
|
|
|
## ⚡ Usage
|
2022-07-15 12:59:22 -05:00
|
|
|
|
|
|
|
```rust
|
2022-07-18 03:54:02 -05:00
|
|
|
use spinoff::{Spinner, Spinners, Color};
|
2022-07-15 12:59:22 -05:00
|
|
|
use std::thread::sleep;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
2022-07-19 13:01:23 -05:00
|
|
|
let spinner = Spinner::new(Spinners::Dots, "Loading...", Color::Blue);
|
2022-07-15 12:59:22 -05:00
|
|
|
sleep(Duration::from_secs(3));
|
|
|
|
spinner.success("Done!");
|
|
|
|
```
|
|
|
|
|
2022-07-16 05:38:43 -05:00
|
|
|
### Update a spinner
|
|
|
|
|
|
|
|
```rust
|
2022-07-18 03:54:02 -05:00
|
|
|
use spinoff::{Spinner, Spinners, Color};
|
2022-07-16 05:38:43 -05:00
|
|
|
use std::thread::sleep;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
2022-07-19 13:01:23 -05:00
|
|
|
let mut spinner = Spinner::new(Spinners::Dots, "Loading...", Color::Red);
|
2022-07-16 05:38:43 -05:00
|
|
|
sleep(Duration::from_secs(3));
|
2022-07-17 07:24:43 -05:00
|
|
|
spinner.update(Spinners::Dots2, "Loading...", None);
|
2022-07-16 05:38:43 -05:00
|
|
|
sleep(Duration::from_secs(3));
|
2022-07-18 12:49:48 -05:00
|
|
|
spinner.stop()
|
2022-07-16 05:38:43 -05:00
|
|
|
```
|
|
|
|
|
2022-07-18 12:46:59 -05:00
|
|
|
### Stop a spinner and persist a symbol and message
|
|
|
|
|
|
|
|
```rust
|
|
|
|
use spinoff::{Spinner, Spinners, Color};
|
|
|
|
use std::thread::sleep;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
2022-07-19 13:01:23 -05:00
|
|
|
let mut spinner = Spinner::new(Spinners::Dots, "Loading...", Color::Green);
|
2022-07-18 12:46:59 -05:00
|
|
|
sleep(Duration::from_secs(3));
|
|
|
|
spinner.stop_and_persist("📜", "Task done.");
|
|
|
|
```
|
|
|
|
|
|
|
|
Other examples can be found in the [documentation](https://docs.rs/spinoff/latest/spinoff/).
|
|
|
|
|
2022-07-16 05:38:43 -05:00
|
|
|
|
2022-07-18 09:36:10 -05:00
|
|
|
## 📖 Documentation
|
2022-07-15 12:59:22 -05:00
|
|
|
|
2022-07-18 09:36:10 -05:00
|
|
|
* All relevant documentation can be found on the [Docs.rs page](https://docs.rs/spinoff/latest/spinoff/).
|
2022-07-19 12:18:13 -05:00
|
|
|
* If you want to see all the available `Spinner` options, check the [`Spinners`](src/utils/spinner_enum.rs) enum.
|
2022-07-15 12:59:22 -05:00
|
|
|
|
2022-07-18 09:36:10 -05:00
|
|
|
## 🔨 Examples
|
2022-07-15 12:59:22 -05:00
|
|
|
|
|
|
|
To run some of the included examples, use:
|
|
|
|
```bash
|
|
|
|
cargo run --example all_spinners
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cargo run --example simple
|
|
|
|
```
|
|
|
|
|
2022-07-18 09:36:10 -05:00
|
|
|
## 🚧 Contributing
|
2022-07-15 12:59:22 -05:00
|
|
|
|
2022-07-18 09:36:10 -05:00
|
|
|
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.](https://github.com/ad4mx/spinoff)
|
2022-07-15 12:59:22 -05:00
|
|
|
|
2022-07-18 09:36:10 -05:00
|
|
|
## 📑 License
|
2022-07-15 12:59:22 -05:00
|
|
|
|
2022-07-18 09:36:10 -05:00
|
|
|
This crate is licensed under the [MIT license](LICENSE).
|