use crate::git::Change;
use clap::Parser;
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(version, about)]
pub struct Cli {
pub old: String,
pub new: String,
#[arg(short, long, default_value = "main.typ")]
pub main: PathBuf,
#[arg(short, long, default_value = "revision-diff.pdf")]
pub output: PathBuf,
#[arg(short = 'C', long)]
pub repository: Option<PathBuf>,
#[arg(long = "path")]
pub paths: Vec<PathBuf>,
#[arg(long = "exclude")]
pub excludes: Vec<PathBuf>,
#[arg(long = "image-function", value_name = "NAME")]
pub image_functions: Vec<String>,
#[arg(long = "debug-dir", value_name = "DIR")]
pub debug_dir: Option<PathBuf>,
#[arg(long = "notices-file", default_value = ".typdiff-notices.typ")]
pub notices_file: PathBuf,
}
impl Cli {
pub fn matches(&self, change: &Change) -> bool {
let candidates = [&change.old_path, &change.new_path];
let included = self.paths.is_empty()
|| self.paths.iter().any(|prefix| candidates.iter().any(|path| path.starts_with(prefix)));
let excluded = self.excludes.iter().any(|prefix| candidates.iter().any(|path| path.starts_with(prefix)));
included && !excluded
}
}