2023-09-02 01:26:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script is used to generate the images for the examples README
|
|
|
|
# It requires the following tools:
|
|
|
|
# - cargo: https://doc.rust-lang.org/cargo/getting-started/installation.html
|
|
|
|
# - gh: https://github.com/cli/cli
|
|
|
|
# - git: https://git-scm.com/
|
2023-10-20 19:41:36 +00:00
|
|
|
# - vhs: https://github.com/charmbracelet/vhs - currently this needs to be installed from the
|
|
|
|
# main branch, as the latest release doesn't support the theme we use or the Screenshot
|
|
|
|
# command. Install using `go install github.com/charmbracelet/vhs@main``
|
|
|
|
# - go: https://golang.org/doc/install
|
|
|
|
# - ttyd: https://github.com/tsl0922/ttyd
|
2023-09-02 01:26:49 +00:00
|
|
|
|
|
|
|
# Exit on error. Append "|| true" if you expect an error.
|
|
|
|
set -o errexit
|
|
|
|
# Exit on error inside any functions or subshells.
|
|
|
|
set -o errtrace
|
|
|
|
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
|
|
|
|
set -o nounset
|
|
|
|
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
|
|
|
|
set -o pipefail
|
|
|
|
# Turn on traces, useful while debugging but commented out by default
|
|
|
|
# set -o xtrace
|
|
|
|
|
|
|
|
# ensure that running each example doesn't have to wait for the build
|
|
|
|
cargo build --examples --features=crossterm,all-widgets
|
|
|
|
|
2024-01-24 16:22:46 +00:00
|
|
|
for tape_path in examples/vhs/*.tape; do
|
|
|
|
tape_file=${tape_path/examples\/vhs\//} # strip the examples/vhs/ prefix
|
|
|
|
gif_file=${tape_file/.tape/.gif} # replace the .tape suffix with .gif
|
|
|
|
~/go/bin/vhs $tape_path --quiet
|
2023-09-02 01:26:49 +00:00
|
|
|
# this can be pasted into the examples README.md
|
2024-01-24 16:22:46 +00:00
|
|
|
echo "[${gif_file}]: https://github.com/ratatui-org/ratatui/blob/images/examples/${gif_file}?raw=true"
|
2023-09-02 01:26:49 +00:00
|
|
|
done
|
|
|
|
git switch images
|
|
|
|
git pull --rebase upstream images
|
|
|
|
cp target/*.gif examples/
|
|
|
|
git add examples/*.gif
|
|
|
|
git commit -m 'docs(examples): update images'
|
|
|
|
gh pr create
|
2023-10-18 11:35:51 +00:00
|
|
|
git sw -
|