Files
attune/packs/examples/actions/list_example.sh
David Culbreth 87d830f952
Some checks failed
CI / Rustfmt (push) Successful in 23s
CI / Cargo Audit & Deny (push) Successful in 30s
CI / Web Blocking Checks (push) Successful in 48s
CI / Security Blocking Checks (push) Successful in 8s
CI / Clippy (push) Failing after 1m55s
CI / Web Advisory Checks (push) Successful in 35s
CI / Security Advisory Checks (push) Successful in 37s
CI / Tests (push) Successful in 8m5s
[wip] cli capability parity
2026-03-06 16:58:50 -06:00

56 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# List Example Action
# Demonstrates JSON Lines output format for streaming results
#
# This script uses pure POSIX shell without external dependencies like jq.
# It reads parameters in DOTENV format from stdin until EOF.
set -e
# Initialize count with default
count=5
# Read DOTENV-formatted parameters from stdin until EOF
while IFS= read -r line; do
case "$line" in
count=*)
# Extract value after count=
count="${line#count=}"
# Remove quotes if present (both single and double)
case "$count" in
\"*\")
count="${count#\"}"
count="${count%\"}"
;;
\'*\')
count="${count#\'}"
count="${count%\'}"
;;
esac
;;
esac
done
# Validate count is a positive integer
case "$count" in
''|*[!0-9]*)
count=5
;;
esac
if [ "$count" -lt 1 ]; then
count=1
elif [ "$count" -gt 100 ]; then
count=100
fi
# Generate JSON Lines output (one JSON object per line)
i=1
while [ "$i" -le "$count" ]; do
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
printf '{"id": %d, "value": "item_%d", "timestamp": "%s"}\n' "$i" "$i" "$timestamp"
i=$((i + 1))
done
exit 0