Skip to content

Commit

Permalink
0.7.0 (#18)
Browse files Browse the repository at this point in the history
* split each spinner into individual features (#17)

* split into features (#15)

* upaded documentation

* readme changes

---------

Co-authored-by: Haruki Jay Shimada <peaske16180@gmail.com>
  • Loading branch information
ad4mx and DrPoppyseed committed Jan 29, 2023
1 parent bcee5d6 commit e3ffc7e
Show file tree
Hide file tree
Showing 10 changed files with 884 additions and 1,407 deletions.
117 changes: 113 additions & 4 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "spinoff"
version = "0.6.0"
version = "0.7.0"
edition = "2021"
authors = ["ad4m"]
description = "Simple to use Rust library for displaying spinners in the terminal"
Expand All @@ -13,7 +13,116 @@ categories = ["command-line-interface"]
include = ["src/**/*", "README.md"]

[dependencies]
maplit = "1.0.2"
strum = { version = "0.24.0", features = ["derive"] }
once_cell = "1.13.0"
colored = "2.0.0"
colored = "2.0.0"
paste = "1.0.11"

[features]
default = ["all"]

all = [
"dots", "dots2", "dots3", "dots4", "dots5", "dots6", "dots7", "dots8", "dots9",
"dots10", "dots11", "dots12", "dots8bit", "line", "line2", "pipe", "simple_dots",
"simple_dots_scrolling", "star", "star2", "flip", "hamburger", "grow_verticle",
"grow_horizontal", "balloon", "balloon2", "noise", "bounce", "box_bounce",
"box_bounce2", "triangle", "arc", "circle", "square_corners", "circle_quarters",
"circle_halves", "squish", "toggle", "toggle2", "toggle3", "toggle4", "toggle5",
"toggle6", "toggle7", "toggle8", "toggle9", "toggle10", "toggle11", "toggle12",
"toggle13", "arrow", "arrow2", "arrow3", "bouncing_bar", "bouncing_ball",
"smiley", "monkey", "hearts", "clock", "earth", "moon", "runner", "pong", "shark",
"material", "weather", "christmas", "grenade", "point", "layer", "beta_wave",
"finger_dance", "fist_bump", "dqpb", "soccer_header", "mindblown", "speaker",
"orange_pulse", "blue_pulse", "orange_blue_pulse", "time_travel", "aesthetic",
"binary", "cute"
]

dots = []
dots2 = []
dots3 = []
dots4 = []
dots5 = []
dots6 = []
dots7 = []
dots8 = []
dots9 = []
dots10 = []
dots11 = []
dots12 = []
dots8bit = []

line = []
line2 = []
pipe = []

simple_dots = []
simple_dots_scrolling = []

star = []
star2 = []
flip = []
hamburger = []
grow_horizontal = []
grow_verticle = []
balloon = []
balloon2 = []
noise = []
bounce = []
box_bounce = []
box_bounce2 = []
triangle = []
arc = []
circle = []
square_corners = []
circle_quarters = []
circle_halves = []
squish = []

toggle = []
toggle2 = []
toggle3 = []
toggle4 = []
toggle5 = []
toggle6 = []
toggle7 = []
toggle8 = []
toggle9 = []
toggle10 = []
toggle11 = []
toggle12 = []
toggle13 = []

arrow = []
arrow2 = []
arrow3 = []

bouncing_bar = []
bouncing_ball = []
smiley = []
monkey = []
hearts = []
clock = []
earth = []
moon = []
runner = []
material = []
pong = []
shark = []
weather = []
christmas = []
grenade = []
point = []
layer = []
beta_wave = []
finger_dance = []
fist_bump = []
dqpb = []
soccer_header = []
mindblown = []
speaker = []
orange_pulse = []
blue_pulse = []
orange_blue_pulse = []
time_travel = []
aesthetic = []
binary = []
cute = []
54 changes: 34 additions & 20 deletions README.md
Expand Up @@ -10,60 +10,73 @@ Add as a dependency to your `Cargo.toml`:

```toml
[dependencies]
spinoff = "0.6.0"
spinoff = "0.7.0"
```

## ⚡ Usage

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

let spinner = Spinner::new(Spinners::Dots, "Loading...", Color::Blue);
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 spinoff::{Spinner, spinners, Color};
use std::thread::sleep;
use std::time::Duration;

let mut spinner = Spinner::new(Spinners::Aesthetic, "Loading...", Color::Red);
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()
```

### Stop a spinner and persist a symbol and message
### Specify an output stream

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

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

### Specify an output stream
## 💫 Spinners
*Note: This has been introduced in version 0.7.0*

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.7.0", features = ["dots, arc, line"] }
```

### Creating your own spinner
You can create your own spinner using the `spinner!` macro:

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

let spinner = Spinner::new_with_stream(Spinners::Line, "Loading...", Color::Yellow, Streams::Stderr);
sleep(Duration::from_secs(3));
spinner.stop_and_persist("📜", "Task done.");
let frames = spinner!([">", ">>", ">>>"], 100);
let sp = Spinner::new(frames, "Hello World!", None);
sleep(Duration::from_millis(800));
sp.stop();
```

### ❗Note for Windows Users
## ❗Note for Windows Users
For colors to work properly, you need to add a few extra lines to your code:
```rust
use colored::control
Expand All @@ -76,18 +89,19 @@ Other examples can be found in the [documentation](https://docs.rs/spinoff/lates
## 📖 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, check the [`Spinners`](src/spinner_enum.rs) enum.
* If you want to see all the available `spinner` options, refer to [the source code](src/spinners.rs).

## ⚙ Examples

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

```bash
cargo run --example simple
```
```bash
cargo run --example stream
```
```bash
cargo run --example stop_and_persist
```

## 🚧 Contributing

Expand Down
11 changes: 0 additions & 11 deletions examples/all_spinners.rs

This file was deleted.

11 changes: 9 additions & 2 deletions examples/simple.rs
@@ -1,8 +1,15 @@
use spinoff::{Color, Spinner, Spinners};
#![allow(unused_imports)]
use spinoff::{spinners, Color, Spinner};
use std::{thread::sleep, time::Duration};

#[cfg(feature = "dots")]
fn main() {
let sp = Spinner::new(Spinners::Dots, "Loading...", Color::Blue);
let sp = Spinner::new(spinners::Dots, "Loading...", Color::Blue);
sleep(Duration::from_millis(8000));
sp.success("Done!");
}

#[cfg(not(feature = "dots"))]
fn main() {
println!("This example requires the 'dots' feature to be enabled.");
}
11 changes: 9 additions & 2 deletions examples/stop_and_persist.rs
@@ -1,8 +1,15 @@
use spinoff::{Color, Spinner, Spinners};
#![allow(unused_imports)]
use spinoff::{spinners, Color, Spinner};
use std::{thread::sleep, time::Duration};

#[cfg(feature = "arc")]
fn main() {
let sp = Spinner::new(Spinners::Arc, "Loading...", Color::Blue);
let sp = Spinner::new(spinners::Arc, "Loading...", Color::Blue);
sleep(Duration::from_secs(5));
sp.stop_and_persist("🍕", "Pizza!");
}

#[cfg(not(feature = "arc"))]
fn main() {
println!("This example requires the 'arc' feature to be enabled.");
}
11 changes: 9 additions & 2 deletions examples/stream.rs
@@ -1,8 +1,15 @@
use spinoff::{Spinner, Spinners, Streams};
#![allow(unused_imports)]
use spinoff::{spinners, Spinner, Streams};
use std::{thread::sleep, time::Duration};

#[cfg(feature = "aesthetic")]
fn main() {
let sp = Spinner::new_with_stream(Spinners::Aesthetic, "Loading in stderr...", None, Streams::Stderr);
let sp = Spinner::new_with_stream(spinners::Aesthetic, "Loading in stderr...", None, Streams::Stderr);
sleep(Duration::from_millis(8000));
sp.success("Done!");
}

#[cfg(not(feature = "aesthetic"))]
fn main() {
println!("This example requires the 'aesthetic' feature to be enabled.");
}

0 comments on commit e3ffc7e

Please sign in to comment.