1
0
Fork 0
mirror of synced 2024-11-22 15:25:34 -05:00

Prompt before zimfw uninstall, unless -q is set

Prompt before uninstalling modules, so users have a chance to review the
list before moving forward with the action.
This commit is contained in:
Eric Nielsen 2020-10-26 19:32:25 -05:00
parent ef4fe38716
commit 78b4711750
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
3 changed files with 23 additions and 16 deletions

View file

@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
_No unreleased changes._
### Fixed
- Prompt before uninstalling modules, unless `-q` is set.
## [1.3.2] - 2020-08-01

View file

@ -1,12 +1,15 @@
_zimfw_uninstall() {
local zopt zdir zmodule
local zopt
if (( _zprintlevel > 0 )) zopt='-v'
for zdir in ${ZIM_HOME}/modules/*(N/); do
zmodule=${zdir:t}
# If _zmodules and _zdisableds do not contain the zmodule
if (( ! ${_zmodules[(I)${zmodule}]} && ! ${_zdisableds[(I)${zmodule}]} )); then
command rm -rf ${zopt} ${zdir} || return 1
local zuninstalls=(${ZIM_HOME}/modules/*(N/:t))
# Uninstall all installed modules not in _zmodules and _zdisableds
zuninstalls=(${${zuninstalls:|_zmodules}:|_zdisableds})
if (( ${#zuninstalls} )); then
_zimfw_print -PR %B${(F)zuninstalls}%b
if (( _zprintlevel <= 0 )) || read -q "?Uninstall ${#zuninstalls} module(s) listed above [y/N]? "; then
_zimfw_print
command rm -rf ${zopt} ${ZIM_HOME}/modules/${^zuninstalls} || return 1
fi
done
fi
_zimfw_print -P '<%= done %>Done with uninstall.'
}

View file

@ -315,22 +315,25 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (previous commit is fbf0fe0)'
print -R 'zimfw version: '${_zversion}' (previous commit is ef4fe38)'
print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a)
}
_zimfw_uninstall() {
local zopt zdir zmodule
local zopt
if (( _zprintlevel > 0 )) zopt='-v'
for zdir in ${ZIM_HOME}/modules/*(N/); do
zmodule=${zdir:t}
# If _zmodules and _zdisableds do not contain the zmodule
if (( ! ${_zmodules[(I)${zmodule}]} && ! ${_zdisableds[(I)${zmodule}]} )); then
command rm -rf ${zopt} ${zdir} || return 1
local zuninstalls=(${ZIM_HOME}/modules/*(N/:t))
# Uninstall all installed modules not in _zmodules and _zdisableds
zuninstalls=(${${zuninstalls:|_zmodules}:|_zdisableds})
if (( ${#zuninstalls} )); then
_zimfw_print -PR %B${(F)zuninstalls}%b
if (( _zprintlevel <= 0 )) || read -q "?Uninstall ${#zuninstalls} module(s) listed above [y/N]? "; then
_zimfw_print
command rm -rf ${zopt} ${ZIM_HOME}/modules/${^zuninstalls} || return 1
fi
done
fi
_zimfw_print -P 'Done with uninstall.'
}