use std::path::PathBuf;
pub use crate::domain::Domain;
pub use crate::import::get_config;
pub use crate::cert::populate_domains;

mod domain;
mod import;
mod cert;

/// Execute the domain checking workflow.
///
/// This function reads a domain configuration file, parses it into a list of
/// [`Domain`] entries, and then enriches each entry by populating additional
/// properties (such as certificate-related data) needed by the application.
///
/// On parse failures, the configuration loader falls back to an empty
/// configuration, resulting in an empty list being returned.
///
/// Arguments
/// - `domain_file`: Path to the configuration file that lists domains to check.
///
/// Returns
/// A vector of [`Domain`] values representing the parsed and populated domain
/// entries. If the configuration cannot be read or parsed, an empty vector is
/// returned.
///
/// Example
/// ```no_run
/// use std::path::PathBuf;
/// use domain_checker_lite::run;
///
/// let domains = run(PathBuf::from("domains.txt"));
/// for d in domains {
///     println!("{d}");
/// }
/// ```
pub fn run(domain_file: PathBuf) -> Vec<Domain> {
    // Returns a Vector of Domain structs, parsed from a config file
    let mut conf: Vec<Domain> = get_config(domain_file).unwrap_or_default();

    // Populates the properties in the Domain object
    populate_domains(&mut conf);

    conf
}