#!/usr/bin/env bash

# omarchy:summary=Install OpenTofu, answering to terraform as well
# omarchy:requires-sudo=true

# Based: tofu through asdf, and a terraform link to it in ~/.local/bin unless a
# terraform is already on PATH.

set -eo pipefail

asdf_data=${ASDF_DATA_DIR:-$HOME/.asdf}
omarchy-pkg-add asdf
export PATH="$asdf_data/shims:$PATH"

echo -e "Installing OpenTofu...\n"
omarchy-dev-env-tool opentofu

if ! omarchy-cmd-present terraform; then
  mkdir -p ~/.local/bin
  ln -sf "$asdf_data/shims/tofu" ~/.local/bin/terraform
fi
