Skip to content

termlens render can only write to stdout, so an SVG has to be shell-redirected #313

Description

@vyncint

Todaytermlens render --svg failing.snap writes to stdout, and that is the only destination. Measured on 0.10.1: render() in crates/termlens-cli/src/main.rs ends in print(&out) with no path handling.

Why it is worth fixing — the documented use is producing an image for a bug report or a CI artifact, and every caller therefore writes > file.svg. That works in a shell and is awkward everywhere else: a Makefile loop, a PowerShell step on the Windows leg, or the report action, which renders several files in a row. It is also the one place where a redirect can silently produce an empty file when the command fails, because the shell truncates before the process runs.

Fix — add --out PATH to render in crates/termlens-cli/src/main.rs: write there instead of stdout, create nothing if the render fails, and keep stdout as the default so existing invocations are unchanged. Document it in RENDER_USAGE and crates/termlens-cli/README.md.

Done when

  • termlens render --svg --out x.svg a.snap writes the same bytes stdout would have.
  • A failing render (unreadable input) exits 2 and leaves no partial file behind.
  • crates/termlens-cli/tests/cli.rs covers both.

A good first contribution: one file, no architecture decisions. Start with
CONTRIBUTING.md
— §1 lists every gate you can run locally, and §3 asks that a change land
with a test. Commits are Conventional Commits and need git commit -s
(DCO). Happy to review a draft PR early.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions