from __future__ import annotations

import argparse
from pathlib import Path

from src.busopt.config import add_model_config_arguments, model_config_from_namespace
from src.busopt.runner import run_nested_gbd, save_result


def build_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(
        description="Run the tri-level bus network design model with standardized inputs and outputs."
    )
    add_model_config_arguments(parser)
    parser.add_argument("--output", type=Path, required=True)
    return parser


def main() -> None:
    args = build_parser().parse_args()
    config = model_config_from_namespace(args)
    save_result(run_nested_gbd(config), args.output)


if __name__ == "__main__":
    main()
