#!/usr/bin/env bash
set -euo pipefail

# Record asciinema demo casts at a consistent terminal size.
# Usage: ./scripts/record-demo.sh [cast-name]
# Without arguments, records all four standard casts.
# With an argument, records just that one (import, pivot, drill, formulas).

CAST_DIR="docs/casts"
COLS=120
ROWS=37
IDLE_CAP=2

mkdir -p "$CAST_DIR"

record() {
    local name="$1"
    local outfile="$CAST_DIR/${name}.cast"
    echo "Recording $name → $outfile (${COLS}x${ROWS}, idle cap ${IDLE_CAP}s)"
    echo "Press Ctrl-D or type 'exit' when done."
    COLUMNS=$COLS LINES=$ROWS asciinema rec -i "$IDLE_CAP" --cols "$COLS" --rows "$ROWS" "$outfile"
    echo "Saved $outfile"
}

if [ $# -gt 0 ]; then
    record "$1"
else
    for name in import pivot drill formulas; do
        record "$name"
        echo ""
    done
fi
