use std::path::PathBuf;
use walkdir::WalkDir;
#[derive(serde::Deserialize, serde::Serialize)]
pub struct Processor {
pub path: PathBuf,
#[serde(default)]
pub depth: usize,
pub command: String,
pub args: Vec<String>,
#[serde(default)]
pub debounce: u64,
#[serde(default)]
pub keep_file: bool,
}
#[derive(serde::Deserialize, serde::Serialize, Default)]
pub struct Config {
pub processors: Vec<Processor>,
}
impl Processor {
pub fn paths(&self) -> impl Iterator<Item = PathBuf> {
WalkDir::new(&self.path)
.max_depth(self.depth)
.into_iter()
.filter_entry(|e| e.file_type().is_dir())
.filter_map(|e| e.ok().map(|e| e.path().to_owned()))
}
}