Skip to content

fix(cli): make ocr --output name the one requested format, or refuse several - #79

Merged
stephen-masters merged 1 commit into
mainfrom
fix/ocr-output-with-format
Oct 24, 2026
Merged

stephen-masters merged 1 commit into
mainfrom
fix/ocr-output-with-format

Conversation

@stephen-masters

@stephen-masters stephen-masters commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #25.

tetrak-ocr ocr page.png --format pdf --output out.pdf wrote the searchable PDF beside the source as page.pdf and then the bare transcript to out.pdf, a text file with a .pdf name that looked like it had worked.

  • With one format requested, through --format or the bare --pdf flag, --output now names that format's file, written by that format's writer. --format pdf --output out.pdf writes a real PDF at out.pdf and nothing beside the source; --format text --output t.txt writes the text format there.
  • With several formats there is no single file to name, so the combination is refused with a message naming the formats, before the OCR runs rather than after paying for it.
  • Without --format, --output still writes the bare transcript exactly as before, so existing scripts are unchanged. --pdf PATH is untouched and remains the other way to name a PDF.
  • outputs.write_to(name, source, transcript, destination) is the one addition: a writer for a chosen path, with no stem rule and no collision guard; outputs.write now goes through it.
  • The command-line guide documents the rule with examples.

Tests: five new CLI cases (one format to the named file as a real PDF, the text writer rather than the bare transcript, the bare --pdf flag, several formats refused before the backend runs, --output alone unchanged) and one for write_to. Fast suite: 425 passed; ruff, Sphinx -W and markdownlint clean.

🤖 Generated with Claude Code

…several

`ocr --format pdf --output out.pdf` wrote the searchable PDF beside the
source and then the bare transcript to out.pdf: a text file with a .pdf
name that looked like it had worked. With one format requested --
through --format or the bare --pdf flag -- --output now names that
format's file, written by that format's writer through the new
outputs.write_to; with several there is no single file to name, so the
combination is refused with a message before the OCR runs. Without
--format, --output still writes the bare transcript as it always has.

Closes #25

Co-authored-by: Yvette Mankerian <yvettekm@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying tetrak with  Cloudflare Pages  Cloudflare Pages

Latest commit: 57d8724
Status: ✅  Deploy successful!
Preview URL: https://a83fb1f9.tetrak.pages.dev
Branch Preview URL: https://fix-ocr-output-with-format.tetrak.pages.dev

View logs

@stephen-masters
stephen-masters merged commit 53d7cf7 into main Oct 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ocr --format pdf --output writes the transcript as text into the .pdf

1 participant