Skip to main content

spinner/
spinner.rs

1//! Demonstrates the spinner during a fake discovery flow.
2//!
3//! ```sh
4//! cargo run --example spinner
5//! ```
6
7use std::{thread::sleep, time::Duration};
8
9use pimalaya_cli::spinner::Spinner;
10
11fn main() {
12    let spinner = Spinner::start("Resolving MX records for example.com…");
13    sleep(Duration::from_secs(1));
14
15    spinner.set_message("Probing imap.example.com:993");
16    sleep(Duration::from_secs(1));
17
18    spinner.set_message("Probing smtp.example.com:465");
19    sleep(Duration::from_secs(1));
20
21    spinner.success("Found IMAP at imap.example.com:993 and SMTP at smtp.example.com:465");
22
23    let spinner = Spinner::start("Probing pop.example.com:995");
24    sleep(Duration::from_secs(1));
25    spinner.failure("No POP server reachable at pop.example.com:995");
26}