feat: Initial support for custom user-defined themes

This commit is contained in:
2025-03-04 18:09:09 -07:00
parent 847de75713
commit 5cb60c317d
11 changed files with 582 additions and 67 deletions
+26 -4
View File
@@ -21,6 +21,7 @@ use tokio_util::sync::CancellationToken;
use crate::app::{log_and_print_error, App, AppConfig};
use crate::cli::{self, Command};
use crate::network::Network;
use crate::ui::theme::ThemeDefinition;
#[cfg(test)]
#[path = "utils_tests.rs"]
@@ -140,10 +141,31 @@ fn colorize_log_line(line: &str, re: &Regex) -> String {
}
pub(super) fn load_config(path: &str) -> Result<AppConfig> {
let file = File::open(path).map_err(|e| anyhow!(e))?;
let reader = BufReader::new(file);
let config = serde_yaml::from_reader(reader)?;
Ok(config)
match File::open(path).map_err(|e| anyhow!(e)) {
Ok(file) => {
let reader = BufReader::new(file);
let config = serde_yaml::from_reader(reader)?;
Ok(config)
}
Err(e) => {
log_and_print_error(format!("Unable to open config file: {e:?}"));
process::exit(1);
}
}
}
pub(super) fn load_theme_config(path: &str) -> Result<Vec<ThemeDefinition>> {
match File::open(path).map_err(|e| anyhow!(e)) {
Ok(file) => {
let reader = BufReader::new(file);
let theme_config = serde_yaml::from_reader(reader)?;
Ok(theme_config)
}
Err(e) => {
log_and_print_error(format!("Unable to open theme file: {e:?}"));
process::exit(1);
}
}
}
pub(super) fn build_network_client(config: &AppConfig) -> Client {