From 665fb7330846c1c782c400e7931aecf28c123446 Mon Sep 17 00:00:00 2001 From: ad4mx Date: Sat, 16 Jul 2022 13:09:22 +0200 Subject: [PATCH] breaking: fixed unnecessary color arguments in methods --- README.md | 2 +- examples/stop_and_persist.rs | 2 +- src/lib.rs | 24 +++++++++++------------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 73acb8b..cb1b75c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ 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!"); +spinner.stop_and_persist("👨‍💻", "Done!"); ``` diff --git a/examples/stop_and_persist.rs b/examples/stop_and_persist.rs index 41d5169..c480c21 100644 --- a/examples/stop_and_persist.rs +++ b/examples/stop_and_persist.rs @@ -5,5 +5,5 @@ use std::time::Duration; fn main() { let sp = spinoff::new(Spinners::Dots, "Loading...", None); sleep(Duration::from_secs(5)); - sp.stop_and_persist("🍕", "Pizza!", "yellow".into()); + sp.stop_and_persist("🍕", "Pizza!"); } diff --git a/src/lib.rs b/src/lib.rs index eb4d4e7..7f8fee1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,9 +139,9 @@ impl Spinner { /// # Notes /// * This method cannot be called if the spinner is already stopped. /// - pub fn stop_with_message(self, msg: StringLiteral, color: Option) { + pub fn stop_with_message(self, msg: StringLiteral) { self.stop(); - println!("{}", init_color(color, msg.into())); + println!("{}", &msg); } /// Deletes the spinner and message and prints a new line with a symbol and message. @@ -154,7 +154,7 @@ impl Spinner { /// /// let sp = spinoff::new(Spinners::Dots, "Hello", None); /// sleep(Duration::from_millis(800)); - /// sp.stop_and_persist("🍕", "Pizza!", None); + /// sp.stop_and_persist("🍕", "Pizza!"); /// ``` /// /// # Panics @@ -163,14 +163,9 @@ impl Spinner { /// # Notes /// * This method will delete the last line of the terminal, so it is recommended to not print anything in between the spinner and the success message. /// * This method cannot be called if the spinner is already stopped. - pub fn stop_and_persist( - self, - symbol: StringLiteral, - msg: StringLiteral, - color: Option, - ) { + pub fn stop_and_persist(self, symbol: StringLiteral, msg: StringLiteral) { self.clear(); - println!("{} {}", init_color(color, symbol.into()), &msg); + println!("{} {}", &symbol, &msg); } /// Deletes the last line of the terminal and prints a success symbol with a message. @@ -190,7 +185,8 @@ impl Spinner { /// * This method cannot be called if the spinner is already stopped. /// * This method will delete the last line of the terminal, so it is recommended to not print anything in between the spinner and the success message. pub fn success(self, msg: StringLiteral) { - self.stop_and_persist("✔", msg, "green".into()); + self.clear(); + println!("{} {}", init_color(Some("green"), "✔".to_string()), &msg); } /// Deletes the last line of the terminal and prints a failure symbol with a message. @@ -211,7 +207,8 @@ impl Spinner { /// * This method cannot be called if the spinner is already stopped. /// pub fn fail(self, msg: StringLiteral) { - self.stop_and_persist("✖", msg, "red".into()); + self.clear(); + println!("{} {}", init_color(Some("red"), "✖".to_string()), &msg); } /// Deletes the last line of the terminal and prints a warning symbol with a message. @@ -232,7 +229,8 @@ impl Spinner { /// * This method will delete the last line of the terminal, so it is recommended to not print anything in between the spinner and the warning message. /// * This method cannot be called if the spinner is already stopped. pub fn warn(self, msg: StringLiteral) { - self.stop_and_persist("⚠ ", msg, "yellow".into()); + self.clear(); + println!("{} {}", init_color(Some("yellow"), "⚠".to_string()), &msg); } /// Deletes the last line of the terminal and prints a new spinner.