1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:15:07 +00:00

feat(purge): add confirm dialog, two-pass column alignment, adaptive footer

- Add confirm_purge_cleanup() to show item count + size and require
  explicit Enter/y confirmation before any deletion
- Two-pass layout in clean_project_artifacts: pass 1 collects data,
  pre-scan finds max path and artifact widths, pass 2 formats with
  consistent column alignment across all rows
- Adaptive footer hints in select_purge_categories degrade gracefully
  on narrow terminals (full → reduced → minimal)
- Use printf '\033[J' to clear stale content when list height shrinks
- Guard empty-array expansions with ${arr[*]-} for set -u safety
- Add BATS tests for confirm_purge_cleanup (Enter confirm, ESC cancel)
This commit is contained in:
tw93
2026-02-26 19:42:42 +08:00
parent 837df390a5
commit d13c0927a6
2 changed files with 214 additions and 28 deletions

View File

@@ -308,6 +308,28 @@ EOF
[ "$status" -eq 0 ]
}
@test "confirm_purge_cleanup accepts Enter" {
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/clean/project.sh"
drain_pending_input() { :; }
confirm_purge_cleanup 2 1024 0 <<< ''
EOF
[ "$status" -eq 0 ]
}
@test "confirm_purge_cleanup cancels on ESC" {
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/clean/project.sh"
drain_pending_input() { :; }
confirm_purge_cleanup 2 1024 0 <<< $'\033'
EOF
[ "$status" -eq 1 ]
}
@test "is_protected_vendor_dir: protects Go vendor" {
mkdir -p "$HOME/www/go-app/vendor"
touch "$HOME/www/go-app/go.mod"