#!/usr/bin/env python3
"""
nterm server entry point.

Usage:
    python run.py
    python run.py --host 0.0.0.0 --port 8080
"""

import argparse
import uvicorn


def main():
    parser = argparse.ArgumentParser(description="nterm — network terminal server")
    parser.add_argument("--host", default="127.0.0.1", help="Bind address (default: 127.0.0.1)")
    parser.add_argument("--port", type=int, default=8765, help="Port (default: 8765)")
    parser.add_argument("--reload", action="store_true", help="Auto-reload on code changes")
    parser.add_argument("--debug", action="store_true", help="Enable debug logging")
    args = parser.parse_args()

    log_level = "debug" if args.debug else "info"

    print(f"\n  nterm 0.5.0")
    print(f"  http://{args.host}:{args.port}\n")

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


if __name__ == "__main__":
    main()
