from __future__ import annotations

import sys

from .check import check_generated
from .emit_index import build_all


def main(argv=None):
    argv = argv or sys.argv[1:]
    if not argv or argv[0] == "all":
        build_all()
        return 0
    if argv[0] == "check":
        check_generated()
        return 0
    raise SystemExit(f"unknown build command: {argv[0]}")


if __name__ == "__main__":
    raise SystemExit(main())
