use colored::*;
pub fn custom(tag: &ColoredString, message: &str, scope: Option<&str>, ln: Option<bool>) {
let pref = match scope {
None => "".to_string(),
Some(p) => format!("[{}]", p),
};
let to_print = format!("{} {} {}", pref.dimmed(), tag, message);
match ln {
Some(false) => print!("{}", to_print),
_ => println!("{}", to_print),
}
}
pub fn head(name: &str, icon: Option<&str>, version: Option<&str>) {
let ver = match version {
None => "".to_string(),
Some(v) => format!("\n\t(v{})\n", v),
};
let ico = match icon {
None => "",
Some(i) => i,
};
println!("\n\t{} {}{} ", ico, name.bold().underline(), ver.dimmed());
}
pub fn info(message: &str, scope: Option<&str>, ln: Option<bool>) {
custom(&"โน".blue().bold(), message, scope, ln);
}
pub fn success(message: &str, scope: Option<&str>, ln: Option<bool>) {
custom(&"โ".green().bold(), message, scope, ln);
}
pub fn warn(message: &str, scope: Option<&str>, ln: Option<bool>) {
custom(&"โ ".yellow().bold(), message, scope, ln);
}
pub fn error(message: &str, scope: Option<&str>, ln: Option<bool>) {
custom(&"โ".red().bold(), message, scope, ln);
}
pub fn wait(message: &str, scope: Option<&str>, ln: Option<bool>) {
custom(&"โฆ".magenta().bold(), message, scope, ln);
}
pub fn done(message: &str, scope: Option<&str>, ln: Option<bool>) {
custom(&"โ".cyan().bold(), message, scope, ln);
}
pub fn remove() {
print!("\r");
}