#!/bin/bash

gh search prs --state=open --review-requested=lunarway/squad-aura --label=dependencies --checks=pending --json repository,number | jq -c '.[]' | \
while read obj ; do
  echo "$obj"
  number=$(jq '.number' <<< "$obj")
  repo=$(jq -r '.repository.nameWithOwner' <<< "$obj")
  gh pr diff "$number" --repo "$repo"
  read -p "Approve (y/N/q)? " -n 1 -r
  if [[ $REPLY =~ ^[Yy]$ ]]
  then
    #gh --repo "$repo" pr review "$number" --approve
    #gh --repo "$repo" pr merge "$number" --squash --delete-branch
    echo "approve stuff"
  fi
  if [[ $REPLY =~ ^[Qq]$ ]]
  then
    echo "you've chosen to stop here!"
    return 1
  fi
done