Skip to content

termlens diff and render cannot read a screen from stdin #317

Description

@vyncint

Today — both subcommands take file paths only. Measured on 0.10.1, load() in crates/termlens-cli/src/main.rs is std::fs::read_to_string(path) with no special case, so - is treated as a filename and fails:

$ termlens render --text - < saved.snap
termlens: -: No such file or directory (os error 2)

Why it is worth fixing — a saved screen most often arrives on a pipe: pulled out of a CI log, produced by another tool, or generated a moment earlier. - for stdin is the universal convention, and the parser already takes a &str rather than a path.

Fix — in load(), treat the path - as "read stdin to a string" and keep everything downstream unchanged. For diff, allow it for at most one of the two operands and say so plainly if both are -, since stdin can only be consumed once. Document it in the usage strings and crates/termlens-cli/README.md.

Done when

  • termlens render --text - < a.snap and termlens diff a.snap - < b.snap both work.
  • termlens diff - - fails with a clear one-line diagnostic and exit code 2.
  • crates/termlens-cli/tests/cli.rs covers the success and the double-stdin refusal.

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