new: added new usage example

This commit is contained in:
ad4mx 2022-07-16 12:38:43 +02:00
parent abf5eb6577
commit 9af1ead1a1

View file

@ -10,11 +10,26 @@ use spinoff::Spinners;
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
let spinner = spinoff::new(Spinners::Dots, "Loading...", "Blue".into()); // Can also be Some("blue") or None let spinner = spinoff::new(Spinners::Dots, "Loading...", "blue".into()); // Can also be Some("blue") or None
sleep(Duration::from_secs(3)); sleep(Duration::from_secs(3));
spinner.success("Done!"); spinner.success("Done!");
``` ```
### Update a spinner
```rust
use spinoff::Spinners;
use std::thread::sleep;
use std::time::Duration;
let mut spinner = spinoff::new(Spinners::Dots, "Loading...", "blue".into());
sleep(Duration::from_secs(3));
spinner = spinner.update(Spinners::Dots2, "Loading...", None);
sleep(Duration::from_secs(3));
spinner.success("Done!");
```
## Documentation ## Documentation
* All documentation can be found on the [Docs.rs page](https://docs.rs/spinoff/latest/spinoff/). * All documentation can be found on the [Docs.rs page](https://docs.rs/spinoff/latest/spinoff/).