#[derive(Debug, Clone)]
pub struct ValidationResult {
pub config_valid: bool,
pub config_error: Option<String>,
pub paths_found: usize,
pub paths_total: usize,
pub missing_paths: Vec<std::path::PathBuf>,
pub base_url_valid: bool,
pub base_url_error: Option<String>,
pub remote_urls_ok: usize,
pub remote_urls_total: usize,
pub remote_url_errors: Vec<(String, String)>,
}
impl Default for ValidationResult {
fn default() -> Self {
Self::new()
}
}
impl ValidationResult {
pub fn new() -> Self {
Self {
config_valid: true, config_error: None,
paths_found: 0,
paths_total: 0,
missing_paths: Vec::new(),
base_url_valid: true, base_url_error: None,
remote_urls_ok: 0,
remote_urls_total: 0,
remote_url_errors: Vec::new(),
}
}
pub fn is_valid(&self) -> bool {
self.config_valid
&& self.missing_paths.is_empty()
&& (self.base_url_valid || self.base_url_error.is_none())
&& self.remote_url_errors.is_empty()
}
pub fn exit_code(&self) -> i32 {
if !self.config_valid {
return 1; }
if !self.missing_paths.is_empty() {
return 2; }
if self.base_url_error.is_some() || !self.remote_url_errors.is_empty() {
return 3; }
0 }
}