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

cmd-docker-options-remove() {
  declare desc="Remove a docker option from application"
  declare cmd="docker-options:remove"
  [[ "$1" == "$cmd" ]] && shift 1
  declare APP="$1"

  verify_app_name "$APP"
  read -ra passed_phases <<<"$(get_phases "$2")"
  shift 2 # everything else passed is the docker option
  [[ -z ${passed_docker_option="$@"} ]] && dokku_log_fail "Please specify docker options to remove from the phase"
  remove_passed_docker_option passed_phases[@] "${passed_docker_option[@]}"
}

cmd-docker-options-remove "$@"
