use antistatic::watcher::FileWatcher;

#[tokio::main]
async fn main() {
    println!("File Watcher Demo - Reactor Pattern");
    println!("====================================\n");

    // Create a new file watcher with reactor
    let mut watcher = FileWatcher::new().expect("Failed to create file watcher");

    // Add event handler - this is the reactor callback
    watcher
        .on_change(|event| {
            println!("\n🔄 File change detected!");
            println!("  Event kind: {:?}", event.kind);
            println!("  Affected paths:");
            for path in &event.paths {
                println!("    - {}", path.display());
            }
        })
        .await;

    // Watch the current directory
    watcher
        .watch(".")
        .expect("Failed to watch current directory");

    println!("👀 Watching current directory for changes...");
    println!("   Try creating, modifying, or deleting files!");
    println!("   Press Ctrl+C to stop\n");

    // Keep the program running
    tokio::signal::ctrl_c()
        .await
        .expect("Failed to listen for Ctrl+C");

    println!("\n👋 Shutting down...");
}
