#!/bin/bash
# ============================================================
# db-clients.sh — CLI database clients (pgcli, mycli)
# ============================================================
# Installs interactive, feature-rich CLI clients for the two
# most common open-source relational databases:
#
#   pgcli  — PostgreSQL client with syntax highlighting, auto-
#             completion, and multi-line editing (official repos)
#   mycli  — MySQL / MariaDB client with the same UX improvements
#             (AUR only, as the upstream package is not in the
#             official Arch repos)
#
# Both tools are built on Python's prompt-toolkit library and
# offer a significantly better interactive experience than the
# stock `psql` and `mysql` CLIs.
#
# This is an optional module because database clients are only
# needed on machines used for database development or
# administration.
# ============================================================

set -euo pipefail
# Load shared logging helpers from the dotfiles lib
source "$(dirname "${BASH_SOURCE[0]}")/../../lib/logging.sh"

# ── pgcli (official repos) ────────────────────────────────────────────────────
# pgcli: PostgreSQL client with auto-complete, syntax highlighting, and
# multi-line query editing.  It also shows the query explain plan inline.
log "Installing pgcli..."
sudo pacman -S --noconfirm --needed pgcli

# ── mycli (AUR) ──────────────────────────────────────────────────────────────
# mycli: MySQL / MariaDB CLI with identical UX improvements to pgcli.
# Available from AUR only because it is not packaged in the official repos.
log "Installing mycli (AUR)..."
yay -S --answerdiff None --answerclean All --noconfirm mycli

log "DB clients installed."
