From 7dc62b28a6dfedcf236bb9c32be73955dddc0f2c Mon Sep 17 00:00:00 2001 From: Dmitrii Shatokhin Date: Sat, 2 Nov 2024 00:26:57 +0100 Subject: [PATCH] feat: improve error messaging and user feedback --- src/main.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 43829a8..ad7f318 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,9 +41,13 @@ fn main() { // Check if the user provided at least one argument (mode) if args.len() < 2 { - let message = format!("{} Usage: {} ", FAILURE, args[0]); - pb.finish_with_message(message); - eprintln!("{} Example: {} transmute", FAILURE, args[0]); + let message = style(format!("{} Wrong usage!", FAILURE)).red().bold(); + let example = style(format!("Follow: {} ", args[0])) + .yellow() + .italic(); + + pb.finish(); + eprintln!("{}\n {}", message, example); std::process::exit(1); } @@ -63,9 +67,11 @@ fn main() { ); } Err(e) => { - let message = format!("{} Dark magic interfered: {}", FAILURE, e); - pb.finish_with_message(message); - eprintln!("{}", style(format!("Error: {}", e)).red().bold()); + let message = style(format!("{} Dark magic interfered!\n {}", FAILURE, e)) + .red() + .bold(); + pb.finish(); + eprintln!("{}", style(format!("{}", message)).red().bold()); std::process::exit(1); } }