Skip to content

Add the texrun compile CLI command #6

Closed

Description

@nishide-dev

背景

MVP の主要インターフェースとして CLI から compile を実行できるようにする。

想定 UX

texrun compile main.tex

機械利用向けに JSON 出力も提供する。

texrun compile --json main.tex

初期オプション候補

  • --json
  • --output <dir>
  • --timeout <duration>
  • --keep-workspace(必要なら hidden/experimental でもよい)
  • --root <dir>(入力として workspace にコピーする範囲。既定は entrypoint のディレクトリ。Implement isolated compile workspaces #4 と合わせて決める)

--output 未指定時の出力先(例: カレントディレクトリ / entrypoint 隣 / texrun-out/)と、既存ファイルを上書きするかどうかを決める。

engine 指定は将来追加できる設計にしつつ、MVP では TeX Live を default としてよい。

出力方針

human-readable mode:

  • 成否
  • 生成 PDF
  • 主要な warning/error
  • 実行時間

JSON mode:

  • CompileResult を基にした安定した構造
  • stdout に JSON 以外を混ぜない
  • 人間向けログは stderr に分離する

Exit code

少なくとも以下を区別する。案:

code 意味
0 success
1 document compile failure(diagnostics あり)
2 CLI usage error(clap の既定と一致)
3 texrun runtime / configuration failure(latexmk 不在など)
4 timeout

timeout を compile failure と同じ code にするかは #3 の outcome 設計に合わせて決める。

--json の場合、runtime failure 時も可能な限り JSON(error オブジェクト)を stdout に出力し、呼び出し側が exit code と JSON の両方で判定できるようにする。

完了条件

  • texrun compile main.tex で PDF を生成できる
  • --json の出力を他プロセスから parse できる
  • compile failure 時にも diagnostics を確認できる
  • texrun --help / texrun compile --help が分かりやすい
  • exit code の定義がドキュメント化されている
  • CLI の振る舞い(help / exit code / JSON 形状)を検証するテストがある(assert_cmd や snapshot test など)

依存

Activity

  1. added this to the MVP milestone on Sep 30, 2026
  2. added
    enhancement
    on Sep 30, 2026
  3. nishide-dev commented on Sep 30, 2026

    @nishide-dev
    OwnerAuthor

    PR #29(#28)レビューからの申し送り: workspace 自体の置き換えを collect 時に検出した場合も現状は ArtifactNotFile になる。exit code / JSON の error code に対応付ける際、WorkspaceChanged 相当に分離するか検討する。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions