2025-03-16 21:05:33 -06:00
|
|
|
/*
|
|
|
|
* Copyright 2025 Bryson Steck <me@brysonsteck.xyz>
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2025-03-16 14:48:31 -06:00
|
|
|
use colored::Colorize;
|
2025-02-17 17:41:21 -07:00
|
|
|
|
2025-03-16 14:48:31 -06:00
|
|
|
pub enum ExitCode {
|
|
|
|
ParseError = 2,
|
|
|
|
FilesystemError = 3,
|
|
|
|
RepositoryError = 4,
|
|
|
|
RemoteError = 5,
|
2025-03-16 16:01:20 -06:00
|
|
|
PushError = 6,
|
|
|
|
FetchError = 7,
|
2025-03-20 22:01:50 -06:00
|
|
|
ConfigError = 8,
|
2025-03-16 14:48:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct ReturnData {
|
|
|
|
pub code: ExitCode,
|
|
|
|
pub msg: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn error(msg: String, code: ExitCode) {
|
|
|
|
eprintln!("{} {}", "error:".red().bold(), msg);
|
|
|
|
quit::with_code(code as u8)
|
2025-03-09 12:16:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn warning(msg: String) {
|
2025-03-16 14:48:31 -06:00
|
|
|
eprintln!("{} {}", "warning:".yellow().bold(), msg)
|
2025-03-09 12:16:51 -06:00
|
|
|
}
|
|
|
|
|
2025-02-17 17:41:21 -07:00
|
|
|
pub fn verbose(level: u8, msg_lvl: u8, msg: String) {
|
2025-03-20 22:01:50 -06:00
|
|
|
if level < msg_lvl {
|
|
|
|
return;
|
|
|
|
};
|
2025-02-17 17:41:21 -07:00
|
|
|
let mut prefix = String::new();
|
2025-03-02 11:47:29 -07:00
|
|
|
for _ in 0..msg_lvl {
|
2025-02-17 17:41:21 -07:00
|
|
|
prefix += "=";
|
|
|
|
}
|
|
|
|
|
|
|
|
prefix += "> ";
|
2025-03-16 14:48:31 -06:00
|
|
|
eprintln!("{}{}", prefix.purple().bold(), msg);
|
2025-03-02 11:47:29 -07:00
|
|
|
}
|