import argparse

import uvicorn

from config.settings import settings
from main import apply_rule_hit_mode


def parse_args(argv=None):
    parser = argparse.ArgumentParser()
    parser.add_argument("--reload", action="store_true")
    parser.add_argument("--rule-hit-mode", choices=["subset", "all"], default="subset")
    return parser.parse_args(argv)


def main():
    args = parse_args()
    apply_rule_hit_mode(args.rule_hit_mode)
    uvicorn.run(
        "main:app",
        host=settings.HOST,
        port=settings.PORT,
        log_level="debug" if settings.DEBUG else "info",
        reload=args.reload,
    )


if __name__ == "__main__":
    main()
