CLI Reference
The TMT CLI is defined by the Cli struct using the clap crate. The file format is inferred from the input file’s extension — no explicit format flag is needed.
Arguments
| Argument | Short | Type | Default | Description |
|---|---|---|---|---|
--input | -i | PathBuf | (required) | Path to the source file (.pdf, .docx, .csv, .tsv). |
--output | -o | PathBuf | (required) | Path where the translated file will be saved. Must share the same extension as --input. |
--src-lang | -s | String | (required) | Source language code: en, ne, or tmg. |
--tgt-lang | -t | String | (required) | Target language code: en, ne, or tmg. Must differ from --src-lang. |
--base-url | — | String | https://tmt.ilprl.ku.edu.np/lang-translate | Override the API base URL. |
--api-token | — | String | (none) | API token. Overrides the TMT_API_TOKEN environment variable. |
--concurrency | — | usize | 2 | Maximum number of simultaneous in-flight API requests. Must be ≥ 1. |
--rate-limit-ms | — | u64 | (none) | Fixed delay in milliseconds between API requests, regardless of concurrency. |
--max-retries | — | u32 | 4 | Number of retries for non-rate-limit failures (e.g., network errors). |
--font-path | — | PathBuf | (none) | Path to a TrueType/OpenType font file. Required for PDF output. |
--dpi | — | u32 | 96 | Resolution (DPI) for PDF page rendering. Must be ≥ 1. |
--jpeg-quality | — | u8 | 85 | JPEG compression quality (1–100) for PDF background images. |
--verbose | — | bool | false | Enable debug-level tracing logs. |
--debug-bboxes | — | bool | false | Draw red rectangles around detected text regions in PDF output. Useful for diagnosing layout issues. |
Concurrency & Rate Limiting
--concurrency controls the capacity of the async Semaphore inside TranslationService — it caps how many translation tasks run in parallel. --rate-limit-ms adds a fixed cooldown delay enforced by a Mutex inside TmtClient, ensuring a minimum spacing between any two requests regardless of the concurrency setting. Both can be used together for fine-grained throughput control.
PDF-Specific Options
Because the PDF pipeline reconstructs documents by rendering translated text over a rasterized background of the original page, --dpi and --jpeg-quality let you trade off between output file size and visual fidelity:
- Higher
--dpi→ sharper background, larger file. - Lower
--jpeg-quality→ smaller file, more compression artifacts.
Debugging Flags
--verbosesets thetracingsubscriber level todebugfor the application (dependencies stay atwarn).--debug-bboxesinstructs the PDF reconstructor to draw bounding boxes around every detected text region, which helps diagnose mis-aligned or missing translated text.