#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"

exec &> /dev/stdout
echo "Starting: $(date -Is)"

FAST_RUN="${1:-}"

if [[ "${FAST_RUN}" = "--fast" ]]; then
  echo 'Doing fast run'
  mbsync EuAndreh
  notmuch new
else
  echo 'Doing normal (slow) run'
  notmuch new
  mbsync EuAndreh &
  mbsync Nubank   &
  mbsync Gmail    &
  wait
  notmuch new
fi

echo "Finishing: $(date -Is)"
