From 869a8f5f1713b8721d825c15eb4a0c45756615d6 Mon Sep 17 00:00:00 2001 From: Eric Nielsen <4120606+ericbn@users.noreply.github.com> Date: Mon, 16 Sep 2024 18:30:09 -0500 Subject: [PATCH] Ask before uninstallng each unused module instead of asking just once for all. Keep printing number of unused modules, even if zero. --- CHANGELOG.md | 5 ++++- src/stage2/50_zimfw_uninstall.zsh.erb | 22 ++++++++++++++-------- zimfw.zsh | 24 +++++++++++++++--------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d931e73..850b22a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -_No unreleased changes._ +### Changed + +- Ask before uninstalling each unused module, instead of asking just once for + all. ## [1.14.0] - 2024-06-25 diff --git a/src/stage2/50_zimfw_uninstall.zsh.erb b/src/stage2/50_zimfw_uninstall.zsh.erb index 5cbc90b..b41df89 100644 --- a/src/stage2/50_zimfw_uninstall.zsh.erb +++ b/src/stage2/50_zimfw_uninstall.zsh.erb @@ -1,11 +1,17 @@ _zimfw_uninstall() { - local zopt - if (( _zprintlevel > 0 )) zopt=-v - if (( ${#_zunused_dirs} )); then - if (( _zprintlevel <= 0 )) || read -q "?Uninstall ${#_zunused_dirs} module(s) listed above [y/N]? "; then - _zimfw_print - command rm -rf ${zopt} ${_zunused_dirs} || return 1 - fi + if (( _zprintlevel <= 0 )); then + command rm -rf ${_zunused_dirs} || return 1 + else + local zunused_dir + print $'Found <%= bold %>'${#_zunused_dirs}$'<%= normal %> unused module(s).' + for zunused_dir in ${_zunused_dirs}; do + if read -q "?Uninstall ${zunused_dir} [y/N]? "; then + print + command rm -rfv ${zunused_dir} || return 1 + else + print + fi + done + print 'Done with uninstall.' fi - _zimfw_print 'Done with uninstall.' } diff --git a/zimfw.zsh b/zimfw.zsh index b7a38f0..8e0fd2b 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -462,7 +462,7 @@ _zimfw_compile() { } _zimfw_info() { - print -R 'zimfw version: '${_zversion}' (built at 2024-09-16 23:05:08 UTC, previous commit is ded640e)' + print -R 'zimfw version: '${_zversion}' (built at 2024-09-16 23:27:18 UTC, previous commit is 3fe3ba2)' local zparam for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do print -R ${(r.22....:.)zparam}${(P)zparam} @@ -470,15 +470,21 @@ _zimfw_info() { } _zimfw_uninstall() { - local zopt - if (( _zprintlevel > 0 )) zopt=-v - if (( ${#_zunused_dirs} )); then - if (( _zprintlevel <= 0 )) || read -q "?Uninstall ${#_zunused_dirs} module(s) listed above [y/N]? "; then - _zimfw_print - command rm -rf ${zopt} ${_zunused_dirs} || return 1 - fi + if (( _zprintlevel <= 0 )); then + command rm -rf ${_zunused_dirs} || return 1 + else + local zunused_dir + print $'Found \E[1m'${#_zunused_dirs}$'\E[0m unused module(s).' + for zunused_dir in ${_zunused_dirs}; do + if read -q "?Uninstall ${zunused_dir} [y/N]? "; then + print + command rm -rfv ${zunused_dir} || return 1 + else + print + fi + done + print 'Done with uninstall.' fi - _zimfw_print 'Done with uninstall.' } _zimfw_upgrade() {