fediloom/src/main.rs
2024-06-03 01:24:43 -05:00

51 lines
1.5 KiB
Rust

// src/main.rs
mod cli;
mod manip;
use glob::glob;
use manip::{Limit, LimitList, MergedLimitList};
fn main() -> std::io::Result<()> {
env_logger::init(); // TODO add more logging & actual error handling
// TODO utilize CLI
// let _cli = cli::Cli::parse();
// TODO parse config file if one is provided
let mut merged_list = MergedLimitList::new();
// Crawl /suspend for suspend lists -> glob pattern: "suspend/**/*.txt"
{
let mut suspend_lists = vec![];
let suspend_paths = glob("suspend/**/*.txt").expect("Bad glob pattern");
for path in suspend_paths.filter_map(|x| x.ok()) {
suspend_lists.extend(LimitList::from_file(path));
// TODO Check if path contains trust value as part of filename when building limitlist
}
for list in suspend_lists {
merged_list.add_limit_list(list, Limit::Suspend);
}
}
// Crawl /silence for silence lists -> glob pattern: "silence/**/*.txt"
{
let mut silence_lists = vec![];
let silence_paths = glob("silence/**/*.txt").expect("Bad glob pattern");
for path in silence_paths.filter_map(|x| x.ok()) {
silence_lists.extend(LimitList::from_file(path));
// TODO Check if path contains trust value as part of filename when building limitlist
}
for list in silence_lists {
merged_list.add_limit_list(list, Limit::Silence);
}
}
merged_list.export_file("suspend.txt", "silence.txt", (50, 33))
}