"""RoohAI CLI entry point."""
import argparse
import os
import uvicorn


def main():
    parser = argparse.ArgumentParser(description="RoohAI voice agent server")
    parser.add_argument("--host", default="0.0.0.0", help="Bind host (default: 0.0.0.0)")
    parser.add_argument("--port", type=int, default=8000, help="Bind port (default: 8000)")
    parser.add_argument("--reload", action="store_true", help="Enable auto-reload for development")
    parser.add_argument("--log-level", default="info", choices=["debug", "info", "warning", "error"], help="Log level (default: info)")
    parser.add_argument(
        "--cors-origins",
        default=None,
        help='Comma-separated allowed CORS origins (default: "*"). '
             "Example: --cors-origins https://myapp.com,https://staging.myapp.com",
    )
    args = parser.parse_args()

    if args.cors_origins is not None:
        os.environ["ROOHAI_CORS_ORIGINS"] = args.cors_origins

    uvicorn.run("server.app:app", host=args.host, port=args.port, reload=args.reload, log_level=args.log_level)


if __name__ == "__main__":
    main()
