Skip to content

Latest commit

 

History

History

examples

Snapshot Showcase

This file showcases snapshot examples generated by the term-transcript CLI app. Consult the generating script for details on preparing the environment.

Basics

Static snapshot

Snapshot of rainbow example

Generating command:

term-transcript exec -T 250ms --palette gjm8 rainbow

(rainbow is an executable for end-to-end tests.)

Static snapshot (pure SVG)

Snapshot of rainbow example

Generating command:

term-transcript exec -T 250ms --pure-svg --palette gjm8 rainbow

Animated snapshot

Animated snapshot of rainbow example

Generating command:

term-transcript exec -T 250ms --palette powershell \
  --pty --window --scroll rainbow 'rainbow --long-lines'

Note the --pty flag to use a pseudo-terminal for capture instead of default pipes.

Configuring console size

Setting width

Wide snapshot

Use --width to control the pixel width of the console, and --hard-wrap to control at which char the console output is hard-wrapped to a new line. It usually makes sense to set these both params: width ≈ hard_wrap * 9 (the exact coefficient depends on the font being used).

Generating command:

term-transcript exec -T 250ms --palette gjm8 \
  --hard-wrap=100 --width=900 'rainbow --long-lines'

Setting scroll height

Small snapshot

Use --scroll=$height to set the maximum pixel height of the snapshot.

Generating command:

term-transcript exec -T 250ms --palette gjm8 \
  --hard-wrap=50 --width=450 --scroll=180 rainbow

Line numbering

Separate numbering for each output

Separate numbering for outputs

Generating command:

term-transcript exec -T 250ms --scroll --palette xterm \
  --line-numbers each-output \
  rainbow 'rainbow --short'

Continuous numbering for outputs

Continuous numbering for outputs

Generating command:

term-transcript exec -T 250ms --scroll --palette powershell \
  --line-numbers continuous-outputs \
  rainbow 'rainbow --short'

Continuous numbering for inputs and outputs

Continuous numbering for inputs and outputs

Generating command:

term-transcript exec -T 250ms --scroll --palette gjm8 \
  --line-numbers continuous \
  rainbow 'rainbow --short'

Same snapshot generated using the pure SVG template (i.e., with the additional --pure-svg flag):

Continuous numbering for inputs and outputs

Numbering with line breaks

As the example below shows, what is numbered are displayed lines obtained after potential line breaking.

Numbering with line breaks

Generating command:

term-transcript exec -T 250ms --palette gjm8 \
  --line-numbers continuous \
  'rainbow --long-lines'

Same snapshot generated using the pure SVG template (i.e., with the additional --pure-svg flag):

Numbering with line breaks, pure SVG

Hiding user inputs

Combined with line numbering and scrolling to test more features.

Hidden user inputs

Generating command:

term-transcript exec -T 250ms --scroll --palette xterm \
  --no-inputs --line-numbers continuous \
  rainbow 'rainbow --short'

Same snapshot generated using the pure SVG template (i.e., with the additional --pure-svg flag):

Hidden user inputs, pure SVG

Custom fonts

Using --styles and --font options, it's possible to use a custom font in the snapshot. For example, the snapshot below uses Fira Mono:

Snapshot with Fira Mono font

Note that the custom font will only be displayed when viewed in the browser if the Content Security Policy of the HTTP server hosting the SVG allows to do so. See the FAQ for more details.

Generating command:

term-transcript exec -T 250ms --palette gjm8 --window \
  --font 'Fira Mono, Consolas, Liberation Mono, Menlo' \
  --styles '@import url(https://code.cdn.mozilla.net/fonts/fira.css);' rainbow

Configuration file

--config-path option allows reading rendering options from a TOML file. This enables configuring low-level template details. The snapshot below uses a configuration file to customize palette colors and scroll animation step / interval.

Snapshot with config read from file

Generating command:

term-transcript exec -T 250ms --config-path config.toml \
  'rainbow --long-lines'

Failed inputs

Some shells may allow detecting whether an input resulted in a failure (e.g., *nix shells allow doing this by comparing the output of echo $? to 0, while in PowerShell $? can be compared to True). Such failures are captured and visually highlighted the default SVG template.

Failures in sh

Snapshot with failing sh commands

Generating command:

term-transcript exec -T 250ms --palette gjm8 --window \
  './non-existing-command' \
  '[ -x non-existing-file ]' \
  '[ -x non-existing-file ] || echo "File is not there!"'

Failures in bash

Captured using a pseudo-terminal, hence colorful grep output.

Snapshot with failing grep in bash

Generating command:

term-transcript exec -T 250ms --palette gjm8 \
  --pty --window --shell bash \
  'ls -l Cargo.lock' \
  'grep -n serge Cargo.lock' \
  'grep -n serde Cargo.lock'

Failures in pwsh

Snapshot with failing pwsh command

term-transcript exec --window --palette gjm8 \
  --shell pwsh './non-existing-command'