#!/bin/bash
# omarchy:summary=List OmarchyCN configuration backups
# omarchy:examples=omarchycn restore list

set -euo pipefail

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

echo "Dev-mirror backups ($CN_DM_BACKUP_ROOT):"
if [[ -d $CN_DM_BACKUP_ROOT ]]; then
  for dir in "$CN_DM_BACKUP_ROOT"/*/; do
    [[ -d $dir ]] || continue
    stamp="${dir%/}"
    stamp="${stamp##*/}"
    echo "  $stamp: $(ls "$dir" | tr '\n' ' ')"
  done
else
  echo "  (none)"
fi

echo "Mirrorlist backups (/etc/pacman.d):"
found="false"
for f in /etc/pacman.d/mirrorlist.omarchycn-bak-*; do
  if [[ -e $f ]]; then
    echo "  ${f##*/}"
    found="true"
  fi
done
if [[ $found == "false" ]]; then
  echo "  (none)"
fi
