#!/usr/bin/env bash

# omarchy:summary=Install the full development bundle: every language, cloud CLI, database, container and desktop tool

# Based: the bundle runs every development row in turn, keeps going past
# one that fails, and names what did not install at the end. Desktop apps
# are skipped on a system with no display; rows for the other OS say so
# themselves and stop.

set -o pipefail

os=$(omarchy-os)
arch=$(uname -m)
graphical=true
if [[ $os != darwin && -z ${DISPLAY:-}${WAYLAND_DISPLAY:-} ]]; then
  graphical=false
fi

rows=(
  "development core"
  "development asdf"
  "tools shell"
  "tools cli"
  "tools belt"
  "tools ssh"
  "tools direnv"
  "tools dotstow"
  "tools cinch"
  "tools drover"
  "tools nix"
  "development cpp"
  "development gnome"
  "development debian"
  "development incus"
  "development docker"
  "development arduino"
  "development mobile"
  "development vagrant"
  "development databases all"
  "dev-env go"
  "dev-env python"
  "dev-env ruby"
  "dev-env rust"
  "dev-env java"
  "dev-env php"
  "dev-env elixir"
  "dev-env zig"
  "dev-env dotnet"
  "development javascript toolchain"
  "development julia"
  "development solana"
  "development solidity"
  "development sui"
  "development socket"
  "cloud aws"
  "cloud azure"
  "cloud gcloud"
  "cloud hcloud"
  "cloud kubernetes"
  "cloud opencloud"
  "cloud ovh"
  "cloud opentofu"
  "cloud packer"
  "cloud pulumi"
  "cloud ansible"
  "editor neovim"
)
if [[ $arch != aarch64 && $arch != arm64 ]]; then
  rows+=("development virtualbox")
fi
if $graphical; then
  rows+=(
    "editor cursor"
    "terminal ghostty"
    "browser chromium"
    "tools angryip"
    "tools blender"
    "tools charles"
    "tools drawio"
    "tools gimp"
    "tools gpgfrontend"
    "tools hoppscotch"
    "tools inkscape"
    "tools libreoffice"
    "tools devtoolbox"
    "tools eyedropper"
    "tools jxplorer"
    "tools netsleuth"
    "tools textpieces"
    "tools wildcard"
    "tools peekaboo"
    "ai anythingllm"
    "ai lm-studio"
    "development gamemaker"
    "development godot"
    "cloud openlens"
    "gaming oh-my-git"
    "service thunderbird"
    "service zoom"
  )
else
  rows+=("tools server")
fi

failed=()
for row in "${rows[@]}"; do
  echo
  echo "==> omarchy install $row"
  # shellcheck disable=SC2086
  omarchy install $row || failed+=("$row")
done

echo
if ((${#failed[@]})); then
  echo "Did not install:" >&2
  printf '  %s\n' "${failed[@]}" >&2
  exit 1
fi
echo "The development bundle is installed."
