<?php
// CLI tester for AOL verification provider
// Usage: php functions/scripts/scan/test_aol_cli.php user@aol.com

if (php_sapi_name() !== 'cli') {
    echo "Run from CLI.\n";
    exit(1);
}

$argvCount = $_SERVER['argc'];
if ($argvCount < 2) {
    echo "Usage: php functions/scripts/scan/test_aol_cli.php <email>\n";
    exit(1);
}

$email = $_SERVER['argv'][1];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Invalid email.\n";
    exit(1);
}

require_once __DIR__ . '/providers/aol.php';

$verifier = new pub_aol_verify($email, 'tester@example.com');
$result = $verifier->verify();
$debug = $verifier->get_debug();
$raw = $verifier->get_debug(true);

echo "Email: $email\n";
if ($result) {
    echo "Result: EXISTS (taken)\n";
} else {
    echo "Result: NOT FOUND (available or unknown)\n";
}

echo "\n-- Debug --\n";
foreach ($debug as $line) {
    echo $line . "\n";
}

echo "\n-- Raw --\n";
foreach ($raw as $entry) {
    echo json_encode($entry, JSON_PRETTY_PRINT) . "\n";
}
