#!/usr/bin/env bash

set -a
source "$HOME/.config/restic/othalan.env"
declare -a flags

# if [[ "$1" == "backup" ]]; then
#   flags=(
#     "--exclude-file" "$HOME/.config/restic/excludes.txt"
#     "--exclude-file" "$HOME/.conda/environments.txt"
#   )
# fi
#
# echo "${flags[@]}"
# assumes subcommand always comes first
case $1 in
  -*) restic "$@" && exit "$?";;
  backup) cmd=backup; shift;;
  *) cmd="$1"; shift;;
esac

if [[ $cmd == "backup" ]]; then
  flags=(
    "--exclude-file" "$HOME/.config/restic/excludes.txt"
    "--exclude-file" "$HOME/.conda/environments.txt"
  )
fi


# echo restic "$@" "${flags[@]}"

restic "$cmd" "${flags[@]}" "$@"