termlens-cli 0.11.11

The termlens command: run a program in a PTY and print its screen, diff two saved screens, render one as SVG, HTML, ANSI, the text format or JSON
# termlens-cli

The `termlens` command: the [termlens](https://crates.io/crates/termlens)
PTY harness at a shell prompt.

```sh
cargo install termlens-cli --locked

termlens inspect --size 120x40 htop          # run a program, print its screen
termlens inspect --ansi ./target/debug/myapp # …in colour
termlens inspect --cwd ./examples ./demo     # …in ./examples, where ./demo is found
termlens diff old.snap new.snap.new          # what changed, cell by cell; exit 1 if anything
termlens render --svg --out failing.svg failing.snap.new
```

A saved screen is the snapshot text format termlens prints (an insta
`.snap`, with or without its header; the block a wait error prints; a
`TERMLENS_ARTIFACT_DIR` file), or the JSON the crate's `serde` feature
writes. `diff` colours the changed cells on a terminal and stays plain in a
pipe; `--color always|never|auto`, and `NO_COLOR` is honoured.

`diff` and `render` read `-` as standard input, for a screen that arrives on
a pipe — out of a CI log, or from the tool that made it a moment earlier.
Only one of `diff`'s two operands can be `-`, since stdin is read once:

```sh
termlens inspect ./myapp | termlens render --svg --out shot.svg -
termlens diff expected.snap -   < actual.snap
```

`--` ends the options of all three commands, so a file whose name begins
with `-` can be named (`termlens render --text -- -x.snap`); a `-` after it
is still standard input. `diff` and `render` refuse an input in the text
format larger than 1 GiB with exit code `2`: the format holds the grid
alone, and the largest, 1000x1000 cells each styled differently, is about
110 MB, so nothing real is near it, and `render --text /dev/zero` stops
there rather than filling memory. JSON has no size limit. It carries the
history and the captured images, which grow with `scrollback(n)` and
`capture_graphics(n)` — 50,000 rows of styled history on 120x40 are
1.25 GiB — so it is read as it arrives, holding memory for the screen and
history it declares rather than for its length.

`render --out PATH` writes there instead of to stdout, and creates nothing
when the render fails. A shell redirect cannot promise that — `> file.svg`
truncates the file before termlens runs, so a failed render leaves an empty
image attached to the bug report.

`inspect --cwd DIR` runs the program in `DIR`, which must already exist. A
relative `DIR` is taken from where termlens runs, and a relative program
path such as `./demo` is found inside `DIR`, where the program runs. The
working directory is part of how a program is normally run, and
`TerminalBuilder::current_dir` had no way through to the command line.

Exit codes: `0` ran; `diff` exits `1` when the screens differ; `2` means the
command itself could not run — bad arguments, an unreadable file, a program
that could not be spawned.

The `.github/actions/report` action in the termlens repository uses this
binary to put failing screens into a pull request's step summary.