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

case "$1" in
  help | nginx:help)
    help_content_func () {
      declare desc="return nginx plugin help content"
      cat<<help_content
    nginx, Interact with Dokku's Nginx proxy
    nginx:build-config <app>, (Re)builds nginx config for given app
    nginx:access-logs <app> [-t], Show the nginx access logs for an application (-t follows)
    nginx:error-logs <app> [-t], Show the nginx error logs for an application (-t follows)
help_content
    }

    if [[ $1 = "nginx:help" ]] ; then
        echo -e 'Usage: dokku nginx[:COMMAND]'
        echo ''
        echo 'Interact with Dokku'"'"'s Nginx proxy.'
        echo ''
        echo 'Additional commands:'
        help_content_func | sort | column -c2 -t -s,
    else
        help_content_func
    fi
  ;;

  *)
    exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
  ;;

esac
