Skip to content

Commit

Permalink
fix: improve output format
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed May 27, 2020
1 parent a430763 commit a0d33a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/packmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})*
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/packmanager/homebrew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit a0d33a5

Please sign in to comment.