from __future__ import annotations

import argparse
from pathlib import Path

from ember.gateway.runtime.bootstrap import reload_gateway_runtime


def cmd_gateway_reload(args: argparse.Namespace) -> int:
    config_path: Path | None = args.config
    context = reload_gateway_runtime(config_path)

    settings_path = config_path or Path.home() / ".ember" / "config.yaml"
    print("Gateway configuration reloaded.")
    print(f"  settings: {settings_path}")
    print(f"  postgres: {context.config.postgres_dsn or 'in-memory'}")
    print(f"  redis: {context.config.redis_url or 'in-memory'}")
    return 0


__all__ = ["cmd_gateway_reload"]
