Skip to content

Commit

Permalink
Merge pull request #24 from persevie/feature/improve-cli-output
Browse files Browse the repository at this point in the history
feat: improve error messaging and user feedback
  • Loading branch information
dmtrshat authored Nov 1, 2024
2 parents 6f74373 + 07e4da1 commit 688c61b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ fn main() {

// Check if the user provided at least one argument (mode)
if args.len() < 2 {
let message = format!("{} Usage: {} <mode>", 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: {} <mode>", args[0]))
.yellow()
.italic();

pb.finish();
eprintln!("{}\n {}", message, example);
std::process::exit(1);
}

Expand All @@ -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);
}
}
Expand Down

0 comments on commit 688c61b

Please sign in to comment.