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

tags_create_cmd() {
  declare desc="creates an images tag for app via command line"
  local cmd="tags:create"
  [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
  local APP="$2"; local IMAGE_TAG="$3"; local IMAGE_REPO=$(get_app_image_repo "$APP")
  verify_app_name "$APP"

  tag_image "$IMAGE_REPO:latest" "$IMAGE_REPO:$IMAGE_TAG"
  dokku_log_info2_quiet "Added $IMAGE_TAG tag to $IMAGE_REPO"
  plugn trigger tags-create "$APP" "$IMAGE_TAG"
}

tags_create_cmd "$@"
