#!/bin/bash

repodef=${REPODEF:-~/.gitty}
[ -f "${repodef}" ] || {
  echo "${repodef} not found." >&2
  exit 1
}
# shellcheck disable=SC1090
. "${repodef}"

[ -z "$1" ] && action="${action}status" || action="${action}$*"
[ -t 1 ] && tput="tput" || tput="true"

for i in ${repos-}; do
  (
    cd "${i}" || exit
    ${tput} bold
    ${tput} setaf 3
    echo "==> ${PWD}"
    ${tput} sgr0

    git "${action}" || exit 1
  ) || exit 1
done
