diff --git a/demos/helpers.sh b/demos/helpers.sh index a83b02033d..6c611d71ef 100644 --- a/demos/helpers.sh +++ b/demos/helpers.sh @@ -39,3 +39,26 @@ comment() { echo -e "\033[0;32m${indented}\033[0m" blank } + +git_config() { + cat <<'EOF' > "$1" +[color] +ui=always +EOF +} + +jj_config() { + cat <<'EOF' > "$1" +[user] +name = "JJ Fan" +email = "jjfan@example.com" + +[operation] +hostname = "jujube" +username = "jjfan" + +[ui] +color="always" +paginate="never" +EOF +} diff --git a/demos/run_script.sh b/demos/run_script.sh new file mode 100755 index 0000000000..c6cec9737d --- /dev/null +++ b/demos/run_script.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -euo pipefail +. "$(dirname "$0")"/helpers.sh + +which term-transcript > /dev/null || echo "\`term-transcipt\` must be installed with e.g. \`cargo binstall term-transcript-cli\`. See also https://github.com/slowli/term-transcript" +which convert > /dev/null || echo "\`convert\` from ImageMagik needs to be installed to create pngs. Only svgs will be created." >&2 + +echo "jj --version: (set PATH to change)" +jj --version + +JJ_CONFIG=$(mktemp --tmpdir jjconfig-XXXX.toml) +export JJ_CONFIG +jj_config "$JJ_CONFIG" + +GIT_CONFIG_GLOBAL=$(mktemp --tmpdir gitconfig-XXXX) +export GIT_CONFIG_GLOBAL +git_config "$GIT_CONFIG_GLOBAL" + +for script in "$@"; do + script_base="${script%.sh}" + script_base="${script_base#demo_}" + (bash "$script" || echo 'SCRIPT FAIL') 2>&1 | tee /dev/stderr | term-transcript capture --no-inputs --out "$script_base".svg "$script_base" + # Resize to 700 width and any height + which convert > /dev/null && convert -resize 700x10000 -colors 50 "$script_base".svg "$script_base".png || true +done