feat: repository architecture for files crate w. added tests

Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
izzy
2026-01-24 01:25:42 +00:00
parent 9c2ae59ecf
commit e896582a5c
25 changed files with 1432 additions and 462 deletions

View File

@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::{collections::HashMap, path::Path};
use cached::proc_macro::cached;
use config::{Config, File, FileFormat};
@@ -94,10 +94,19 @@ static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
}
}
for path in CONFIG_SEARCH_PATHS {
if std::path::Path::new(path).exists() {
builder = builder.add_source(File::new(path, FileFormat::Toml));
let cwd = std::env::current_dir().unwrap();
let mut cwd: Option<&Path> = Some(&cwd);
while let Some(path) = cwd {
for config_path in CONFIG_SEARCH_PATHS {
let config_path = path.join(config_path);
if config_path.exists() {
builder = builder
.add_source(File::new(config_path.to_str().unwrap(), FileFormat::Toml));
}
}
cwd = path.parent();
}
builder.build().unwrap()