#snapshot #terminal #svg

app term-transcript-cli

CLI wrapper for term-transcript

3 unstable releases

Uses new Rust 2021

0.2.0 Jun 12, 2022
0.2.0-beta.1 Jan 6, 2022
0.1.0 Jun 1, 2021

#99 in Testing

MIT/Apache

240KB
5.5K SLoC

term-transcript CLI

Build Status License: MIT OR Apache-2.0 rust 1.57+ required

This crate provides command-line interface for term-transcript. It allows capturing terminal output to SVG and testing the captured snapshots.

Installation

Install with

cargo install --locked term-transcript-cli
# This will install `term-transcript` executable, which can be checked
# as follows:
term-transcript --help

Specify --features portable-pty in the installation command to enable the pseudo-terminal (PTY) support (note that PTY capturing still needs to be explicitly switched on when running term-transcript commands). Without this feature, console app output is captured via OS pipes, which means that programs dependent on isatty checks or getting term size can produce different output than if launched in an actual shell (no coloring, no line wrapping etc.).

Usage

  • The capture subcommand captures output from stdin, renders it to SVG and outputs SVG to stdout.
  • The exec subcommand executes one or more commands in the shell, captures their outputs, renders to an SVG image and outputs it to stdout.
  • The test subcommand allows testing snapshots from the command line.
  • The print subcommand parses an SVG snapshot and outputs it to the command line.

Launch the CLI with the --help option for more details about arguments for each subcommand.

Examples

This example creates a snapshot of the rainbow script and then tests it.

Testing rainbow example

The snapshot itself is tested, too! It also shows that SVG output by the program is editable; in the snapshot, this is used to highlight command-line args and to change color of comments in the user inputs.

The test command can compare colors as well:

Testing color match

Another snapshot created by capturing help output from a pseudo-terminal (the --pty flag):

Output of test-transcript --help

Using PTY enables coloring output by default and formatting dependent on the terminal size.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in term-transcript by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.1–7MB
~117K SLoC