use super::Recipe;
pub struct CompiledRecipe {
pub recipe: Recipe,
pub matcher: regex::Regex,
}
impl CompiledRecipe {
pub fn compile(recipe: Recipe) -> anyhow::Result<Self> {
let matcher = regex::Regex::new(&recipe.match_command)?;
Ok(Self { recipe, matcher })
}
pub fn matches(&self, command: &str) -> bool {
self.matcher.is_match(command)
}
}