#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"

cmd-trace-on() {
  declare desc="enables trace mode"
  declare cmd="trace"
  [[ "$1" == "$cmd" ]] && shift 1

  dokku_log_info1 "Enabling trace mode"
  [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc"
  echo "export DOKKU_TRACE=1" >"$DOKKU_ROOT/.dokkurc/DOKKU_TRACE"
}

cmd-trace-on "$@"
