Initial path matching

This commit is contained in:
2025-05-03 02:48:28 -07:00
commit 20bf33fa05
7 changed files with 796 additions and 0 deletions

33
src/main.rs Normal file
View File

@ -0,0 +1,33 @@
use walkdir::WalkDir;
pub mod manifest;
fn main() {
let file = std::fs::read_to_string("./test.toml").unwrap();
let x: manifest::Manifest = toml::from_str(&file).unwrap();
let rules = x
.rules
.iter()
.map(|rule| (rule.regex(), rule.action))
.collect::<Vec<_>>();
let walker = WalkDir::new("./target").into_iter();
for entry in walker {
let e = entry.unwrap();
let p = e.path();
let s = p.to_str().unwrap();
if !p.is_file() {
continue;
}
let m = rules
.iter()
.find(|(r, _)| r.is_match(s))
.map(|x| x.1.clone());
println!(" {m:?} {s}")
}
}