use std::path::Path;
use anyhow::Result;
use guardy::scan::Scanner;
fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter("guardy=debug")
.init();
println!("Testing streaming Scanner implementation...\n");
let scanner = Scanner::new()?;
println!("Test 1: Scanning current directory...");
let result = scanner.scan(&[Path::new(".").to_path_buf()])?;
println!(" Files scanned: {}", result.files_scanned);
println!(" Files skipped: {}", result.files_skipped);
println!(" Processing errors: {}", result.processing_errors);
println!(" Matches found: {}", result.total_matches);
println!(" Duration: {} ms", result.scan_duration_ms);
let src_dir = Path::new("src");
if src_dir.exists() {
println!("\nTest 2: Scanning src directory...");
let src_result = scanner.scan(&[src_dir.to_path_buf()])?;
println!(" Files scanned: {}", src_result.files_scanned);
println!(" Files skipped: {}", src_result.files_skipped);
println!(" Processing errors: {}", src_result.processing_errors);
println!(" Matches found: {}", src_result.total_matches);
println!(" Duration: {} ms", src_result.scan_duration_ms);
}
let tests_dir = Path::new("tests");
if tests_dir.exists() {
println!("\nTest 3: Scanning tests directory...");
let tests_result = scanner.scan(&[tests_dir.to_path_buf()])?;
println!(" Files scanned: {}", tests_result.files_scanned);
println!(" Files skipped: {}", tests_result.files_skipped);
println!(" Processing errors: {}", tests_result.processing_errors);
println!(" Matches found: {}", tests_result.total_matches);
println!(" Duration: {} ms", tests_result.scan_duration_ms);
}
if result.scan_duration_ms > 0 {
println!("\nPerformance Summary (from initial scan):");
println!(
" Files per second: {:.0}",
result.files_scanned as f64 * 1000.0 / result.scan_duration_ms as f64
);
}
Ok(())
}