darachhat
feat: build production-ready Khmer Document Corpus v0.2.0 with Typer CLI, PyMuPDF, Polars, and DI architecture
c4e128a | """ | |
| Khmer Document Corpus CLI (corpus / kdc) | |
| Production CLI built with Typer, Rich, and Loguru. | |
| """ | |
| from __future__ import annotations | |
| import typer | |
| from rich.console import Console | |
| from app.utils.container import Container | |
| from cli.commands import export, ingest, metadata, preview, stats, upload, validate | |
| app = typer.Typer( | |
| name="corpus", | |
| help="Khmer Document Corpus command-line dataset management tool.", | |
| no_args_is_help=True, | |
| add_completion=False, | |
| ) | |
| corpus_app = typer.Typer( | |
| name="corpus", | |
| help="Corpus management sub-commands.", | |
| no_args_is_help=True, | |
| ) | |
| # Attach each command module to corpus_app | |
| corpus_app.add_typer(ingest.app, name="ingest") | |
| corpus_app.add_typer(validate.app, name="validate") | |
| corpus_app.add_typer(preview.app, name="preview") | |
| corpus_app.add_typer(metadata.app, name="metadata") | |
| corpus_app.add_typer(stats.app, name="stats") | |
| corpus_app.add_typer(export.app, name="export") | |
| corpus_app.add_typer(upload.app, name="upload") | |
| # Add corpus command group to main app | |
| app.add_typer(corpus_app, name="corpus") | |
| # Also attach directly at root for dual syntax (`corpus ingest` AND `corpus corpus ingest`) | |
| app.add_typer(ingest.app, name="ingest") | |
| app.add_typer(validate.app, name="validate") | |
| app.add_typer(preview.app, name="preview") | |
| app.add_typer(metadata.app, name="metadata") | |
| app.add_typer(stats.app, name="stats") | |
| app.add_typer(export.app, name="export") | |
| app.add_typer(upload.app, name="upload") | |
| def main(ctx: typer.Context) -> None: | |
| """Initialize dependency injection container.""" | |
| ctx.obj = Container.build() | |
| console = Console() | |
| if __name__ == "__main__": | |
| app() | |