docs: record initial v0.1.0 demo GIF + fix record-demo.sh argument parsing
Some checks are pending
ci / check (push) Waiting to run
Some checks are pending
ci / check (push) Waiting to run
* assets/demo.gif: 1100x720, ~30s, recorded with vhs from scripts/demo.tape. Covers: --version, repo view (auto-detect), issue list, pr list, api /version + jq, selective JSON, fj --help. * scripts/record-demo.sh: the prior Write didn't persist the rewrite, so the file was still the asciinema version and treated `--gif-only` as an output path. Updated to be vhs-based with proper flag parsing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
61cfd85254
commit
f4709e9c1b
BIN
assets/demo.gif
Normal file
BIN
assets/demo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 139 KiB |
|
|
@ -1,51 +1,68 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Record an asciinema demo of fj. The result is a .cast file you can:
|
# Record the fj README demo from scripts/demo.tape using vhs.
|
||||||
# - Upload to asciinema.org via `asciinema upload dist/demo.cast`
|
|
||||||
# - Embed as a static SVG/GIF via `agg` (https://github.com/asciinema/agg)
|
|
||||||
# - Link from README.md
|
|
||||||
#
|
#
|
||||||
# Requires: asciinema, fj (installed and authenticated), `jq` for nicer output.
|
# vhs is from Charmbracelet (https://github.com/charmbracelet/vhs):
|
||||||
|
# a declarative tape format that drives a headless terminal and writes
|
||||||
|
# GIF/MP4/WebM directly. Reproducible, scriptable, no manual typing.
|
||||||
|
#
|
||||||
|
# Pre-flight:
|
||||||
|
# * `brew install vhs` (or download from the vhs releases page)
|
||||||
|
# * `cargo build --release && ln -sf $PWD/target/release/fj ~/.local/bin/fj`
|
||||||
|
# * `fj auth login --host rasterhub.com`
|
||||||
|
#
|
||||||
|
# Outputs:
|
||||||
|
# assets/demo.gif embed in README
|
||||||
|
# assets/demo.mp4 optional, higher-fidelity for social cards
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ./scripts/record-demo.sh # records dist/demo.cast
|
# ./scripts/record-demo.sh # records both outputs
|
||||||
# ./scripts/record-demo.sh foo.cast # records to foo.cast
|
# ./scripts/record-demo.sh --gif-only # GIF only (faster)
|
||||||
#
|
|
||||||
# The session below is deliberately short (~30 seconds) and covers what
|
|
||||||
# someone reading the README in their first 10 seconds cares about.
|
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
OUT="${1:-dist/demo.cast}"
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
mkdir -p "$(dirname "$OUT")"
|
|
||||||
|
|
||||||
if ! command -v asciinema >/dev/null 2>&1; then
|
GIF_ONLY=0
|
||||||
cat >&2 <<EOF
|
case "${1:-}" in
|
||||||
asciinema not found.
|
--gif-only) GIF_ONLY=1 ;;
|
||||||
macOS: brew install asciinema
|
"") ;;
|
||||||
Linux: pipx install asciinema
|
--help|-h)
|
||||||
EOF
|
sed -n '/^# /{s/^# \{0,1\}//;p;}' "$0" | head -25
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unknown arg: $1 (try --help)" >&2
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
require() {
|
||||||
|
local cmd=$1 hint=$2
|
||||||
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||||
|
echo "missing $cmd. $hint" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
require vhs "Install with: brew install vhs"
|
||||||
|
require fj "Build with: cargo build --release && ln -sf \$PWD/target/release/fj ~/.local/bin/fj"
|
||||||
|
|
||||||
|
if ! fj auth status >/dev/null 2>&1; then
|
||||||
|
echo "fj is not authenticated. Run: fj auth login --host rasterhub.com" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v fj >/dev/null 2>&1; then
|
mkdir -p assets
|
||||||
echo "fj not found on PATH; build it first (cargo build --release)" >&2
|
|
||||||
exit 1
|
if [ "$GIF_ONLY" = 1 ]; then
|
||||||
|
TAPE=$(mktemp -t fj-demo.XXXXXX.tape)
|
||||||
|
trap 'rm -f "$TAPE"' EXIT
|
||||||
|
grep -v '^Output assets/demo\.mp4' scripts/demo.tape > "$TAPE"
|
||||||
|
vhs "$TAPE"
|
||||||
|
else
|
||||||
|
vhs scripts/demo.tape
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Drive a representative session through asciinema.
|
|
||||||
# Idle pauses keep readability up; trim them in post if you want a snappier
|
|
||||||
# embedded GIF.
|
|
||||||
asciinema rec \
|
|
||||||
--overwrite \
|
|
||||||
--idle-time-limit 2 \
|
|
||||||
--title "fj: a CLI for Forgejo" \
|
|
||||||
--command "bash $(dirname "$0")/_demo-session.sh" \
|
|
||||||
"$OUT"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "✓ Recorded $OUT"
|
echo "✓ wrote assets/demo.gif"
|
||||||
echo ""
|
[ "$GIF_ONLY" = 1 ] || echo "✓ wrote assets/demo.mp4"
|
||||||
echo "Next:"
|
|
||||||
echo " asciinema play $OUT # preview"
|
|
||||||
echo " asciinema upload $OUT # publish (returns a URL)"
|
|
||||||
echo " agg $OUT $OUT.gif # render to GIF"
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue