#!/usr/bin/env python3
"""
ozone-wadmin — Ozone/verification-labeler operations, env-var mode.

Reads all config from environment variables. Use this when you have
already set the relevant vars in your shell, or when targeting a
non-production environment.

For production use, run ./ozone-wadmin-prod instead, which reads
config from k8s and sets up the required port-forward automatically.

Required env vars:
    OZONE_HOST               Full URL of the Ozone instance.
    OZONE_ADMIN_PASSWORD     Ozone admin password.
    OZONE_LABELER_DID        DID of the labeler account.
    OZONE_LABELER_PASSWORD   AT Protocol password of the labeler account.

Optional:
    OZONE_LABELER_PDS_HOST   Override PDS host for the labeler account
                             (defaults to pds_host; set this when using
                             a port-forward).

Usage:
    ./ozone-wadmin --help
    ./ozone-wadmin verification verify <did> --account-type personal [options]
    ./ozone-wadmin verification revoke <did>
"""

import os
import sys
from pathlib import Path

SCRIPT_DIR = Path(__file__).parent.resolve()
VENV_PYTHON = SCRIPT_DIR / "pds-wadmin-modules" / ".venv" / "bin" / "python3"

if not VENV_PYTHON.exists():
    print(f"ERROR: venv not found at {VENV_PYTHON}", file=sys.stderr)
    print(
        "Run: cd pds-wadmin-modules && python3 -m venv .venv && "
        ".venv/bin/pip install -e .",
        file=sys.stderr,
    )
    sys.exit(1)

os.execve(
    str(VENV_PYTHON),
    [str(VENV_PYTHON), "-m", "wadmin.ozone_cli"] + sys.argv[1:],
    os.environ,
)
