/**
 * `spectral logout` — remove the persisted Aexol credentials.
 *
 * Idempotent: missing config is not an error. Always exits 0 unless the
 * filesystem itself misbehaves (in which case we surface the OS error).
 */
import pc from "picocolors";
import { CONFIG_FILE, deleteConfig } from "../config.js";
export async function runLogout() {
    try {
        const removed = await deleteConfig();
        if (removed) {
            process.stdout.write(pc.green(`✓ Logged out. Removed ${CONFIG_FILE}\n`));
        }
        else {
            process.stdout.write(pc.dim("Already logged out.\n"));
        }
    }
    catch (err) {
        const msg = err instanceof Error ? err.message : String(err);
        process.stderr.write(pc.red(`✗ Failed to remove ${CONFIG_FILE}: ${msg}\n`));
        process.exit(1);
    }
}
