"""Application management CLI: ``python -m photo_pipeline {serve,migrate}``.""" from __future__ import annotations import argparse from typing import Sequence from photo_pipeline.config import Config from photo_pipeline.db import run_migrations def main(argv: Sequence[str] | None = None) -> int: parser = argparse.ArgumentParser(prog="photo_pipeline") commands = parser.add_subparsers(dest="command", required=True) commands.add_parser("serve", help="Run the API server") commands.add_parser("migrate", help="Upgrade the database to the latest revision") args = parser.parse_args(argv) config = Config.from_env() config.database_path.parent.mkdir(parents=True, exist_ok=True) if args.command == "migrate": run_migrations(config.database_url) return 0 import uvicorn from photo_pipeline.api.app import create_app uvicorn.run(create_app(config), host=config.host, port=config.port) return 0 if __name__ == "__main__": raise SystemExit(main())