add common
This commit is contained in:
parent
953b2efd83
commit
28c1bfd832
1 changed files with 38 additions and 0 deletions
38
src/common.rs
Normal file
38
src/common.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
use colored::Colorize;
|
||||
|
||||
pub enum ExitCode {
|
||||
ParseError = 2,
|
||||
FilesystemError = 3,
|
||||
RepositoryError = 4,
|
||||
RemoteError = 5,
|
||||
PushError = 6,
|
||||
FetchError = 7,
|
||||
ConfigError = 8,
|
||||
HaltError = 130,
|
||||
}
|
||||
|
||||
pub struct ReturnData {
|
||||
pub code: ExitCode,
|
||||
pub msg: String,
|
||||
}
|
||||
|
||||
pub fn error(msg: String) {
|
||||
eprintln!("{} {}", "error:".red().bold(), msg);
|
||||
}
|
||||
|
||||
pub fn warning(msg: String) {
|
||||
eprintln!("{} {}", "warning:".yellow().bold(), msg)
|
||||
}
|
||||
|
||||
pub fn verbose(level: u8, msg_lvl: u8, msg: String) {
|
||||
if level < msg_lvl {
|
||||
return;
|
||||
};
|
||||
let mut prefix = String::new();
|
||||
for _ in 0..msg_lvl {
|
||||
prefix += "=";
|
||||
}
|
||||
|
||||
prefix += "> ";
|
||||
eprintln!("{}{}", prefix.purple().bold(), msg);
|
||||
}
|
Loading…
Add table
Reference in a new issue