Skip to main content

Automation (CLI)

Use structured output and shell pipelines to automate GrantFlow.

JSON pipelines

Extract Role IDs
grantflow roles list --output json | jq -r '.[].id'

Batch process items

Batch Processing
grantflow roles list --output json \
| jq -r '.[].id' \
| while read -r RID; do
grantflow roles get "$RID" --output json | jq '{id, name, maxDuration}'
done | jq -s '.'

Retry logic for transient errors

Retry Logic
retry() {
local tries=${1:-5} delay=${2:-2}
shift 2
local n=1
until "$@"; do
if (( n >= tries )); then
echo "Command failed after $tries attempts" >&2
return 1
fi
sleep $((delay * n))
n=$((n+1))
done
}

retry 5 2 grantflow audit list --limit 100 --output json > audit.json

See also:

  • Getting Started (CLI) → ../../getting-started/cli.md#scripting-automation