feat(demos): add various demo scripts for showcasing Dragonfly's terminal features, including action links, file watching, keyword highlighting, and structured output
This commit is contained in:
1 parent
5e1e592d87
commit
58df7d6cd5
7 files changed
+320
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Purpose: Print text patterns that Dragonfly action links can recognize.
|
||||
# Run: bash scripts/demo-action-links.sh
|
||||
# Docs: docs-site/docs/guide/terminal.md
|
||||
# Settings: Enable action links before running; open a link with Ctrl/Cmd + click.
|
||||
|
||||
cat <<'EOF'
|
||||
Action link matcher demo
|
||||
========================
|
||||
|
||||
IPv4 samples:
|
||||
- primary gateway: 192.0.2.1
|
||||
- cache node: 198.51.100.24
|
||||
- api endpoint: 203.0.113.42
|
||||
|
||||
host:port samples:
|
||||
- app.example.test:8080
|
||||
- db.internal.test:5432
|
||||
- ssh-gateway.test:2222
|
||||
- metrics.service.test:9100
|
||||
|
||||
archive filename samples:
|
||||
- backup-2026-04-13.tar.gz
|
||||
- release-v0.7.0.zip
|
||||
- logs-rolling-01.tgz
|
||||
- artifacts-2026-04-13.tar.xz
|
||||
|
||||
Mixed line:
|
||||
- connect to 203.0.113.42 then inspect backup-2026-04-13.tar.gz on db.internal.test:5432
|
||||
EOF
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Purpose: Append visible changes to a file so Dragonfly's auto-upload prompt can be triggered.
|
||||
# Run: bash scripts/demo-file-watch.sh /path/to/file [iterations] [delay_seconds]
|
||||
# Docs: docs-site/docs/guide/file-transfer.md
|
||||
# Settings: First open a remote file from Dragonfly so the local temp copy is being watched.
|
||||
|
||||
TARGET_FILE=${1:-./demo-file-watch-target.txt}
|
||||
ITERATIONS=${2:-5}
|
||||
DELAY_SECONDS=${3:-1}
|
||||
|
||||
mkdir -p "$(dirname "$TARGET_FILE")"
|
||||
|
||||
if [[ ! -f "$TARGET_FILE" ]]; then
|
||||
printf '# Dragonfly file watch demo\n' > "$TARGET_FILE"
|
||||
fi
|
||||
|
||||
printf 'Updating %s for %s iterations with %ss delay.\n' "$TARGET_FILE" "$ITERATIONS" "$DELAY_SECONDS"
|
||||
|
||||
for ((i = 1; i <= ITERATIONS; i++)); do
|
||||
printf '\n[%s] auto-upload demo change %02d\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$i" >> "$TARGET_FILE"
|
||||
printf 'status=modified source=demo-file-watch iteration=%02d\n' "$i" >> "$TARGET_FILE"
|
||||
printf 'Wrote iteration %02d to %s\n' "$i" "$TARGET_FILE"
|
||||
sleep "$DELAY_SECONDS"
|
||||
done
|
||||
|
||||
printf 'File watch demo finished. If Dragonfly opened this file, you should have seen upload prompts.\n'
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Purpose: Print realistic terminal-style scenarios that exercise the built-in rules
|
||||
# in src/lib/keywordHighlightPresets.ts.
|
||||
# Run: bash scripts/demo-keyword-highlight-presets.sh
|
||||
# Docs: docs-site/docs/guide/terminal.md
|
||||
# Settings: Enable keyword highlighting before running.
|
||||
|
||||
if [[ "${NO_COLOR:-}" != "" ]]; then
|
||||
RESET=""
|
||||
BOLD=""
|
||||
CYAN=""
|
||||
else
|
||||
RESET=$'\033[0m'
|
||||
BOLD=$'\033[1m'
|
||||
CYAN=$'\033[36m'
|
||||
fi
|
||||
|
||||
section() {
|
||||
printf '\n%s%s== %s ==%s\n' "$BOLD" "$CYAN" "$1" "$RESET"
|
||||
}
|
||||
|
||||
section "Deploy health check"
|
||||
cat <<'EOF'
|
||||
2026-04-13T09:17:00Z INFO deploy target=prod-bj-1 version=v0.7.0 operator="release-bot"
|
||||
2026-04-13T09:17:01Z DEBUG command="./deploy.sh --env prod --tag v0.7.0 --dry-run"
|
||||
2026-04-13T09:17:02Z NOTICE release channel=stable revision=1.18.2 elapsed=245ms
|
||||
2026-04-13T09:17:03Z SUCCESS completed successfully host=192.168.1.10 duration=2.4s size=128MB
|
||||
EOF
|
||||
|
||||
section "Service startup log"
|
||||
cat <<'EOF'
|
||||
[web] 2026/04/13 09:18:10 info starting api-server on 0.0.0.0:8080 build=1.18.2
|
||||
[web] 2026/04/13 09:18:11 debug loaded config from "/etc/dragonfly/app.json"
|
||||
[web] 2026/04/13 09:18:12 warn deprecated option --legacy-auth=true will be removed in beta
|
||||
[web] 2026/04/13 09:18:13 notice public endpoint https://dragonfly.example.test/docs?tab=terminal
|
||||
[web] 2026/04/13 09:18:14 success health check passed in 5ms
|
||||
EOF
|
||||
|
||||
section "Failure and retry"
|
||||
cat <<'EOF'
|
||||
2026-04-13T09:19:20Z ERROR failed to connect upstream=db.internal.test:5432 attempt=3 retry_in=30 sec
|
||||
2026-04-13T09:19:21Z FATAL exception=timeout panic trace_id=123e4567-e89b-12d3-a456-426614174000
|
||||
2026-04-13T09:19:22Z DEBUG opts="--host db.internal.test --port 5432 -v"
|
||||
2026-04-13T09:19:23Z INFO fallback address=2001:db8::10 state=null mode=verbose
|
||||
EOF
|
||||
|
||||
section "Security and auth"
|
||||
cat <<'EOF'
|
||||
auth[otp] issuer="Dragonfly" user='ops@example.test' code=042631 period=30s
|
||||
ssh[client] host=203.0.113.42 fingerprint="SHA256:AbCdEf123456" status=ok
|
||||
config[policy] strict=true allow_none=false allow_debug=true
|
||||
EOF
|
||||
|
||||
section "File and artifact operations"
|
||||
cat <<'EOF'
|
||||
download release-v0.7.0.zip -> /tmp/releases/release-v0.7.0.zip size=64 MiB elapsed=1.25s
|
||||
extract backup-2026-04-13.tar.gz to "/srv/backups/current" result=done
|
||||
upload artifacts-2026-04-13.tar.xz bytes=512MB speed=10kbps remaining=4h
|
||||
EOF
|
||||
|
||||
section "Structured values"
|
||||
cat <<'EOF'
|
||||
metrics: cpu=87.5% mem=1.5GB rss=512 bytes uptime=7days
|
||||
flags: enabled=true readonly=false pointer=nullptr sentinel=EOF
|
||||
network: mac=AA:BB:CC:DD:EE:FF ws=wss://stream.example.test/socket ftp=ftp://mirror.example.test/releases/v0.7.0.tar.gz
|
||||
ops: expr=[] {} () == && ++ -- += value=0xff ratio=-0.75 note="quoted string value"
|
||||
EOF
|
||||
|
||||
section "Mixed summary line"
|
||||
cat <<'EOF'
|
||||
2026-04-13T09:20:00Z INFO release=v0.7.0 host=192.168.1.10 url=https://dragonfly.example.test elapsed=45s size=128MB state=success
|
||||
EOF
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Purpose: Print a structured pseudo-session that looks good when Dragonfly recording is enabled.
|
||||
# Run: bash scripts/demo-recording-session.sh
|
||||
# Docs: docs-site/docs/guide/terminal.md, docs-site/docs/getting-started/quick-start.md
|
||||
# Settings: Start recording in Dragonfly before running for the best capture.
|
||||
|
||||
DELAY_SECONDS=${DELAY_SECONDS:-0.35}
|
||||
PROMPT=${PROMPT:-'operator@dragonfly-demo:~/workspace$'}
|
||||
|
||||
emit() {
|
||||
printf '%s\n' "$1"
|
||||
sleep "$DELAY_SECONDS"
|
||||
}
|
||||
|
||||
emit "$PROMPT pwd"
|
||||
emit "/home/operator/workspace"
|
||||
emit "$PROMPT git status --short"
|
||||
emit " M configs/app.yml"
|
||||
emit "?? docs/screenshots-plan.md"
|
||||
emit "$PROMPT ./deploy/check-health.sh"
|
||||
emit "[INFO] checking api.example.test:8080"
|
||||
emit "[INFO] checking db.internal.test:5432"
|
||||
emit "[WARN] background job queue depth is above target"
|
||||
emit "[SUCCESS] web, worker, and scheduler are reachable"
|
||||
emit "$PROMPT tail -n 3 logs/app.log"
|
||||
emit "2026-04-13T09:21:10Z INFO startup complete"
|
||||
emit "2026-04-13T09:21:11Z WARN cache warmup slower than baseline"
|
||||
emit "2026-04-13T09:21:12Z ERROR retryable timeout contacting 203.0.113.42"
|
||||
emit "$PROMPT echo 'recording demo complete'"
|
||||
emit "recording demo complete"
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Purpose: Create mild short-lived CPU and disk activity for remote resource monitor screenshots.
|
||||
# Run: bash scripts/demo-remote-stats.sh [duration_seconds]
|
||||
# Docs: docs-site/docs/guide/terminal.md
|
||||
# Settings: Run on a remote SSH host after enabling remote resource monitoring.
|
||||
|
||||
DURATION_SECONDS=${1:-20}
|
||||
WORKERS=${WORKERS:-2}
|
||||
PAYLOAD_MB=${PAYLOAD_MB:-8}
|
||||
|
||||
TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/dragonfly-stats-demo.XXXXXX")
|
||||
PAYLOAD_FILE="$TMP_DIR/payload.bin"
|
||||
END_TIME=$((SECONDS + DURATION_SECONDS))
|
||||
PIDS=()
|
||||
|
||||
cleanup() {
|
||||
for pid in "${PIDS[@]:-}"; do
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
wait "$pid" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
rm -rf "$TMP_DIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
hash_once() {
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum "$1" >/dev/null
|
||||
elif command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" >/dev/null
|
||||
else
|
||||
cksum "$1" >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
printf 'Preparing %s MiB payload in %s\n' "$PAYLOAD_MB" "$TMP_DIR"
|
||||
dd if=/dev/zero of="$PAYLOAD_FILE" bs=1M count="$PAYLOAD_MB" status=none
|
||||
|
||||
worker() {
|
||||
while (( SECONDS < END_TIME )); do
|
||||
hash_once "$PAYLOAD_FILE"
|
||||
done
|
||||
}
|
||||
|
||||
for ((i = 1; i <= WORKERS; i++)); do
|
||||
worker &
|
||||
PIDS+=("$!")
|
||||
done
|
||||
|
||||
while (( SECONDS < END_TIME )); do
|
||||
cp "$PAYLOAD_FILE" "$TMP_DIR/copy.bin"
|
||||
wc -c < "$TMP_DIR/copy.bin" >/dev/null
|
||||
rm -f "$TMP_DIR/copy.bin"
|
||||
printf '[stats-demo] remaining=%02ds workers=%s payload=%sMiB temp_dir=%s\n' "$((END_TIME - SECONDS))" "$WORKERS" "$PAYLOAD_MB" "$TMP_DIR"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
wait
|
||||
printf 'Remote stats demo complete.\n'
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Purpose: Emit paced line-by-line output for line-number and timestamp gutter screenshots.
|
||||
# Run: bash scripts/demo-terminal-gutter.sh
|
||||
# Docs: docs-site/docs/guide/terminal.md, docs-site/docs/getting-started/quick-start.md
|
||||
# Settings: Enable line numbers and/or timestamps before running.
|
||||
|
||||
DELAY_SECONDS=${DELAY_SECONDS:-0.25}
|
||||
TOTAL_LINES=${TOTAL_LINES:-18}
|
||||
|
||||
printf 'Starting paced output demo with delay=%ss total_lines=%s\n' "$DELAY_SECONDS" "$TOTAL_LINES"
|
||||
|
||||
for ((i = 1; i <= TOTAL_LINES; i++)); do
|
||||
case $((i % 6)) in
|
||||
1) prefix='[scan]' ;;
|
||||
2) prefix='[sync]' ;;
|
||||
3) prefix='[check]' ;;
|
||||
4) prefix='[info]' ;;
|
||||
5) prefix='[warn]' ;;
|
||||
0) prefix='[done]' ;;
|
||||
esac
|
||||
|
||||
printf '%s step=%02d message="pane output sample for gutter screenshots"\n' "$prefix" "$i"
|
||||
sleep "$DELAY_SECONDS"
|
||||
done
|
||||
|
||||
printf 'Paced output demo complete.\n'
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Purpose: Generate stable colorful terminal output for screenshots and keyword-highlighting demos.
|
||||
# Run: bash scripts/demo-terminal-output.sh
|
||||
# Docs: README.md, docs-site/docs/guide/terminal.md, docs-site/docs/intro.md
|
||||
# Settings: Best viewed after enabling keyword highlighting; action links are optional.
|
||||
|
||||
if [[ "${NO_COLOR:-}" != "" ]]; then
|
||||
RESET=""
|
||||
BOLD=""
|
||||
DIM=""
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
else
|
||||
RESET=$'\033[0m'
|
||||
BOLD=$'\033[1m'
|
||||
DIM=$'\033[2m'
|
||||
RED=$'\033[31m'
|
||||
GREEN=$'\033[32m'
|
||||
YELLOW=$'\033[33m'
|
||||
BLUE=$'\033[34m'
|
||||
MAGENTA=$'\033[35m'
|
||||
CYAN=$'\033[36m'
|
||||
fi
|
||||
|
||||
section() {
|
||||
printf '\n%s%s== %s ==%s\n' "$BOLD" "$CYAN" "$1" "$RESET"
|
||||
}
|
||||
|
||||
log_line() {
|
||||
local color=$1
|
||||
shift
|
||||
printf '%s%s%s\n' "$color" "$*" "$RESET"
|
||||
}
|
||||
|
||||
section "Dragonfly terminal output demo"
|
||||
log_line "$DIM" "2026-04-13T09:15:30Z [demo] session=alpha host=203.0.113.10 task=deploy-preview"
|
||||
log_line "$BLUE" "INFO Loading release bundle version=v0.7.0 size=128MiB duration=2.4s"
|
||||
log_line "$GREEN" "SUCCESS SSH authentication completed for operator@203.0.113.10"
|
||||
log_line "$YELLOW" "WARN High latency detected: 182ms over 3 samples"
|
||||
log_line "$RED" "ERROR retryable failure while opening artifact cache; retry in 5s"
|
||||
log_line "$MAGENTA" "DEBUG env=staging feature_flag=terminal-gutter trace_id=550e8400-e29b-41d4-a716-446655440000"
|
||||
|
||||
section "Structured log samples"
|
||||
log_line "$DIM" "2026-04-13 09:16:01 app[web.1]: request_id=req-001 method=GET path=/health status=200 duration=12ms"
|
||||
log_line "$DIM" "2026-04-13 09:16:02 app[worker.2]: queue=sync-jobs processed=24 failed=0"
|
||||
log_line "$DIM" "2026-04-13 09:16:03 app[worker.2]: queue=alerts processed=24 failed=1 retry_in=30s"
|
||||
log_line "$RED" "panic: connection pool exhausted after 32 attempts"
|
||||
log_line "$GREEN" "backup completed successfully at 2026-04-13 09:16:30"
|
||||
|
||||
section "Match-friendly tokens"
|
||||
log_line "$BOLD" "datetime=2026-04-13T09:17:00Z number=4096 size=512MB duration=45s version=1.18.2"
|
||||
log_line "$BOLD" "uuid=123e4567-e89b-12d3-a456-426614174000 address=2001:db8::10 constant=MAX_RETRY_COUNT"
|
||||
log_line "$BOLD" "status=SUCCESS next_window=2026-04-13T09:20:00Z"
|
||||
|
||||
section "Final summary"
|
||||
log_line "$GREEN" "3 services healthy"
|
||||
log_line "$YELLOW" "1 warning requires review"
|
||||
log_line "$RED" "1 transient error captured for screenshot contrast"
|
||||
Reference in new issue
Block a user