#!/usr/bin/env python3
"""mail/index_mail — deprecated. Use bin/brain/index.go --rebuild --with-mail.

Ladybug corrupts its WAL on bulk-insert into an already-indexed DB, so this
shim always rebuilds (repo corpus + var/mail). Conversion stays in mail/import.
"""
from __future__ import annotations

import os
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2]


def main(argv: list[str]) -> int:
    print(
        "bin/mail/index_mail is deprecated; use bin/brain/index.go --rebuild --with-mail",
        file=sys.stderr,
    )
    index = ROOT / "bin" / "kb" / "index"
    os.execv(sys.executable, [sys.executable, str(index), "--rebuild", "--with-mail", *argv])
    return 1


if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
