"""xiaobai-datahub process entry."""

from __future__ import annotations

import argparse

from datahub.hub import build_hub
from datahub.httpapp import serve
from datahub.settings import load_settings


def main() -> None:
    parser = argparse.ArgumentParser(description="xiaobai-datahub")
    parser.add_argument("--host", default=None)
    parser.add_argument("--port", type=int, default=None)
    args = parser.parse_args()
    settings = load_settings()
    if args.host:
        settings.host = args.host
    if args.port:
        settings.port = args.port
    hub = build_hub(settings)
    serve(hub, settings.host, settings.port)


if __name__ == "__main__":
    main()
