File size: 1,652 Bytes
c4e128a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
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")


@app.callback()
def main(ctx: typer.Context) -> None:
    """Initialize dependency injection container."""
    ctx.obj = Container.build()


console = Console()

if __name__ == "__main__":
    app()