use anyhow::{Result, bail}; use clap::Parser; use std::path::PathBuf; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] pub struct Args { /// Path to the input JSON configuration file. #[arg(short, long)] pub input: PathBuf, /// Path to the output directory for downloaded rule files. #[arg(short, long)] pub output: PathBuf, /// Number of concurrent download operations. #[arg(long, default_value_t = 10)] pub concurrency: usize, /// The new domain to use for rewriting rule URLs. #[arg(long)] pub domain: Option, /// The path on the domain for the rewritten rule URLs. #[arg(long, name = "rule-path")] pub rule_path: Option, } impl Args { /// Validates that domain and rule_path are either both present or both absent. pub fn validate_domain_and_rule_path(&self) -> Result<()> { if self.domain.is_some() != self.rule_path.is_some() { bail!("--domain and --rule-path must be used together."); } Ok(()) } }