Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

ArgumentShortTypeDefaultDescription
--input-iPathBuf(required)Path to the source file (.pdf, .docx, .csv, .tsv).
--output-oPathBuf(required)Path where the translated file will be saved. Must share the same extension as --input.
--src-lang-sString(required)Source language code: en, ne, or tmg.
--tgt-lang-tString(required)Target language code: en, ne, or tmg. Must differ from --src-lang.
--base-urlStringhttps://tmt.ilprl.ku.edu.np/lang-translateOverride the API base URL.
--api-tokenString(none)API token. Overrides the TMT_API_TOKEN environment variable.
--concurrencyusize2Maximum number of simultaneous in-flight API requests. Must be ≥ 1.
--rate-limit-msu64(none)Fixed delay in milliseconds between API requests, regardless of concurrency.
--max-retriesu324Number of retries for non-rate-limit failures (e.g., network errors).
--font-pathPathBuf(none)Path to a TrueType/OpenType font file. Required for PDF output.
--dpiu3296Resolution (DPI) for PDF page rendering. Must be ≥ 1.
--jpeg-qualityu885JPEG compression quality (1–100) for PDF background images.
--verboseboolfalseEnable debug-level tracing logs.
--debug-bboxesboolfalseDraw 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

  • --verbose sets the tracing subscriber level to debug for the application (dependencies stay at warn).
  • --debug-bboxes instructs the PDF reconstructor to draw bounding boxes around every detected text region, which helps diagnose mis-aligned or missing translated text.