#!/usr/bin/env bash
[[ " help repo:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

case "$1" in
  help | repo:help)
    help_content_func () {
      declare desc="return repo plugin help content"
      cat<<help_content
    repo:gc <app>, Runs 'git gc --agressive' against the application's repo
    repo:purge-cache <app>, Deletes the contents of the build cache stored in the repository
help_content
    }

    if [[ $1 = "repo:help" ]] ; then
        echo -e 'Usage: dokku repo[:COMMAND]'
        echo ''
        echo "Runs commands that interact with the app's repo"
        echo ''
        echo 'Additional commands:'
        help_content_func | sort | column -c2 -t -s,
    else
        help_content_func
    fi
    ;;

  *)
    exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
    ;;

esac
