#!/bin/bash
# omarchy:summary=Show current pacman mirror profile and servers
# omarchy:examples=omarchycn mirror status

set -euo pipefail

source "$OMARCHY_PATH/cn/lib/mirror.sh"

if [[ -f $CN_PROFILE_FILE ]]; then
  echo "Profile: $(<"$CN_PROFILE_FILE")"
else
  echo "Profile: not managed by OmarchyCN"
fi

echo "Mirrorlist: $CN_MIRRORLIST"
echo "Servers:"
grep -E '^Server' "$CN_MIRRORLIST" | sed 's/^/  /'

backups=("$CN_MIRRORLIST".omarchycn-bak-*)
if [[ -e ${backups[0]} ]]; then
  echo "Backups: ${#backups[@]} (latest: ${backups[-1]##*/})"
fi
