From a0d33a536363447d2c05e70c553f8ae993927c03 Mon Sep 17 00:00:00 2001 From: Rami3L Date: Wed, 27 May 2020 16:46:29 +0800 Subject: [PATCH] fix: improve output format --- src/exec.rs | 16 ++++++++++++---- src/packmanager.rs | 2 +- src/packmanager/homebrew.rs | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/exec.rs b/src/exec.rs index 9e35f2099ed..5bef6a3a172 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -199,21 +199,29 @@ pub fn cmd_str(cmd: &str, subcmd: &[&str], kws: &[&str], flags: &[&str]) -> Stri /// Print out the command after the given prompt. pub fn print_cmd(cmd: &str, subcmd: &[&str], kws: &[&str], flags: &[&str], prompt: &str) { - println!("{:>8} {}", prompt.green(), cmd_str(cmd, subcmd, kws, flags)); + println!( + "{:>8} `{}`", + prompt.green().bold(), + cmd_str(cmd, subcmd, kws, flags) + ); } /// Print out the command after the given prompt (dry run version). pub fn print_dryrun(cmd: &str, subcmd: &[&str], kws: &[&str], flags: &[&str], prompt: &str) { - println!("{:>8} {}", prompt.green(), cmd_str(cmd, subcmd, kws, flags)); + println!( + "{:>8} `{}`", + prompt.green().bold(), + cmd_str(cmd, subcmd, kws, flags) + ); } /// Print out a message after the given prompt. pub fn print_msg(msg: &str, prompt: &str) { - println!("{:>8} {}", prompt.green(), msg); + println!("{:>8} {}", prompt.green().bold(), msg); } pub fn print_err(err: impl std::error::Error, prompt: &str) { - eprintln!("{:>8} {}", prompt.red(), err); + eprintln!("{:>8} {}", prompt.bright_red().bold(), err); } /// Check if an executable exists by name (consult `$PATH`) or by path. diff --git a/src/packmanager.rs b/src/packmanager.rs index 9a2c7be1dee..fe5370cab2b 100644 --- a/src/packmanager.rs +++ b/src/packmanager.rs @@ -11,7 +11,7 @@ macro_rules! make_pm { ($( $(#[$meta:meta])* $method:ident ), *) => { $($(#[$meta])* fn $method(&self, _kws: &[&str], _flags: &[&str]) -> std::result::Result<(), crate::error::Error> { - std::result::Result::Err(format!("`{}` unimplemented", stringify!($method)).into()) + std::result::Result::Err(format!("Operation `{}` unimplemented", stringify!($method)).into()) })* }; } diff --git a/src/packmanager/homebrew.rs b/src/packmanager/homebrew.rs index 60297ab8a00..b70107e4420 100644 --- a/src/packmanager/homebrew.rs +++ b/src/packmanager/homebrew.rs @@ -182,10 +182,10 @@ impl PackManager for Homebrew { if RMTREE_MISSING.find(&err_msg).is_some() { print_msg( - "`rmtree` is not installed. You may try installing it with the following command:", + "`rmtree` is not installed. You may install it with the following command:", PROMPT_INFO, ); - print_msg("brew tap beeftornado/rmtree", PROMPT_INFO); + print_msg("`brew tap beeftornado/rmtree`", PROMPT_INFO); return Err("`rmtree` required".into()); }