from typing import Annotated import typer import src.build as build import src.config as config from src.edition import Edition app = typer.Typer() @app.command() def main( edition: Annotated[list[Edition], typer.Option(help="Course to build, can be specified multiple times.")] = [ # noqa: B006 -- default value is required for typer Edition.instegs, Edition.harec, Edition.uppgradering, ], input: Annotated[str | None, typer.Option("--input", "-i", help="Content source directory.")] = None, output: Annotated[str | None, typer.Option("--output", "-o", help="Destination directory to build to.")] = None, render_editions: Annotated[bool, typer.Option(help="Skip building editions.")] = True, render_solutions: Annotated[bool, typer.Option(help="Skip building solutions.")] = True, build_zip: Annotated[bool, typer.Option(help="Whether to build a zip file of the output.")] = False, ) -> None: conf = config.Config(content_path=input, build_path=output) bd = build.Build(conf) # Build surrounding website bd.build_website() if render_editions: # Build individual editions for e in edition: bd.build_edition(e) if render_solutions: # Build solution pages bd.build_solutions() # Copy assets to build folder bd.build_assets() bd.build_question_index() bd.build_index() if build_zip: # Build zip file of output bd.build_zip() if __name__ == "__main__": app()