use spinners::{Spinner, Spinners};

pub struct AppSpinner {
    spinner: Spinner,
}

impl AppSpinner {
    pub fn new(message: &str) -> Self {
        let spinner = Spinner::new(Spinners::Dots, message.to_string());
        Self { spinner }
    }

    pub fn stop_with_success_message(&mut self, success_message: &str) {
        self.spinner
            .stop_and_persist("✔", success_message.to_string());
    }

    pub fn stop_with_error_message(&mut self, error_message: &str) {
        self.spinner
            .stop_and_persist("✘", error_message.to_string());
    }
}
