forked from samuelvanderwaal/metaboss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspinner.rs
37 lines (35 loc) · 1.4 KB
/
spinner.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use indicatif::{ProgressBar, ProgressStyle};
pub fn create_spinner(msg: &'static str) -> ProgressBar {
let spinner = ProgressBar::new_spinner();
spinner.enable_steady_tick(10);
spinner.set_style(
ProgressStyle::default_spinner()
.tick_strings(&["▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸", ""])
.template("{spinner:.blue}{msg}"),
);
spinner.set_message(msg);
spinner
}
pub fn create_alt_spinner(msg: &'static str) -> ProgressBar {
let spinner = ProgressBar::new_spinner();
spinner.enable_steady_tick(10);
spinner.set_style(
ProgressStyle::default_spinner()
.tick_strings(&["▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸", ""])
.template("{spinner:.blue}{msg}"),
);
spinner.set_message(msg);
spinner.finish_and_clear();
let spinner = ProgressBar::new_spinner();
spinner.enable_steady_tick(80);
spinner.set_style(
ProgressStyle::default_spinner()
.tick_strings(&[
"[ ]", "[= ]", "[== ]", "[=== ]", "[ ===]", "[ ==]", "[ =]", "[ ]",
"[ =]", "[ ==]", "[ ===]", "[====]", "[=== ]", "[== ]", "[= ]",
])
.template("{spinner:.blue} {msg}"),
);
spinner.set_message(msg);
spinner
}