whoxydse 0.1.1

Discover related top-level domains using Whoxy API: historical WHOIS, reverse WHOIS, and DNS verification
use crate::models::{DiscoveryStats, DomainResult, PivotAttributes};
use colored::*;

/// Display progress message
pub fn progress(message: &str) {
    println!("{} {}", "".bright_blue().bold(), message.bright_white());
}

/// Display success message
pub fn success(message: &str) {
    println!("{} {}", "".bright_green().bold(), message.bright_green());
}

/// Display warning message
pub fn warning(message: &str) {
    println!("{} {}", "".bright_yellow().bold(), message.bright_yellow());
}

/// Display error message
pub fn error(message: &str) {
    println!("{} {}", "".bright_red().bold(), message.bright_red());
}

/// Display section header
pub fn section_header(title: &str) {
    println!("\n{}", title.bright_cyan().bold().underline());
}

/// Display a warning when pivot attributes do not match the target domain (lower-fidelity results).
/// Advises the user to validate ownership and mentions that WHOIS history can improve confidence.
pub fn display_fidelity_warning() {
    warning("Some pivot attributes do not match the target domain — results may have lower fidelity.");
    println!(
        "  {} Validate discovered domains to ensure ownership (e.g. current WHOIS or historical records).",
        "".bright_yellow()
    );
    println!(
        "  {} Higher-fidelity: attributes tied to the domain (e.g. email @yourdomain.com, company name matching the domain).",
        "".bright_yellow()
    );
    println!(
        "  {} Additional verification: cross-check companies/contacts against WHOIS history (more API usage).",
        "".bright_yellow()
    );
}

/// Display discovered pivot attributes
pub fn display_pivot_attributes(attrs: &PivotAttributes, config: &crate::models::PivotConfig) {
    section_header("Discovered Pivot Attributes");

    if config.use_name && !attrs.names.is_empty() {
        println!("\n{} Names:", "Names:".bright_white().bold());
        for name in &attrs.names {
            println!("{}", name.bright_white());
        }
    }

    if config.use_email && !attrs.emails.is_empty() {
        println!("\n{} Emails:", "Emails:".bright_white().bold());
        for email in &attrs.emails {
            println!("{}", email.bright_white());
        }
    }

    if config.use_company && !attrs.companies.is_empty() {
        println!("\n{} Companies:", "Companies:".bright_white().bold());
        for company in &attrs.companies {
            println!("{}", company.bright_white());
        }
    }
}

/// Display discovered domains
pub fn display_domains(domains: &[DomainResult]) {
    section_header("Discovered Domains");

    if domains.is_empty() {
        warning("No domains found");
        return;
    }

    println!("\nFound {} domain(s):\n", domains.len().to_string().bright_green().bold());

    for (idx, domain) in domains.iter().enumerate() {
        let number = format!("{}.", idx + 1);
        println!(
            "  {} {}",
            number.bright_cyan(),
            domain.domain_name.bright_white()
        );
        if let Some(ref created) = domain.created_date {
            println!("      Created: {}", created.bright_black());
        }
        if let Some(ref expiry) = domain.expiry_date {
            println!("      Expires: {}", expiry.bright_black());
        }
    }
}

/// Display statistics
pub fn display_stats(stats: &DiscoveryStats) {
    section_header("Statistics");

    println!(
        "  Total domains found:        {}",
        stats.total_domains_found.to_string().bright_white()
    );
    println!(
        "  After de-duplication:       {}",
        stats.after_deduplication.to_string().bright_white()
    );
    println!(
        "  After DNS verification:     {}",
        stats.after_dns_verification.to_string().bright_green().bold()
    );

    if !stats.domains_by_attribute.is_empty() {
        println!("\n  Domains by attribute:");
        for (attr, count) in &stats.domains_by_attribute {
            println!("    {}: {}", attr.bright_cyan(), count.to_string().bright_white());
        }
    }
}

/// Display welcome message
pub fn welcome(target_domain: &str) {
    println!("\n{}", "=".repeat(60).bright_cyan());
    println!(
        "{}",
        format!("WhoxyDSE - Domain Discovery Tool").bright_cyan().bold()
    );
    println!("{}", "=".repeat(60).bright_cyan());
    println!("\nTarget domain: {}\n", target_domain.bright_white().bold());
}

/// Display final summary
pub fn summary(verified_count: usize) {
    println!("\n{}", "=".repeat(60).bright_cyan());
    if verified_count > 0 {
        success(&format!(
            "Discovery complete! Found {} verified domain(s).",
            verified_count
        ));
    } else {
        warning("Discovery complete, but no verified domains were found.");
    }
    println!("{}", "=".repeat(60).bright_cyan());
}