<?php
require __DIR__ . '/../bootstrap.php';

use Gestoreasy\Core\Tenant\ConnectionManager;
use Gestoreasy\Core\Tenant\TenantAdmin;

$tenant = $argv[1] ?? 'default';
try {
    $pdo = ConnectionManager::forTenant($tenant);
    $res = TenantAdmin::seedDefaultAdmin($pdo);
    echo json_encode(['ok' => true, 'tenant' => $tenant, 'result' => $res], JSON_UNESCAPED_UNICODE) . "\n";
} catch (\Throwable $e) {
    echo json_encode(['ok' => false, 'error' => $e->getMessage()], JSON_UNESCAPED_UNICODE) . "\n";
}