From 7139771ec6c91bdecd8b1508224b396b7dac3f54 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Tue, 10 Dec 2019 18:19:01 -0500 Subject: [PATCH] Rename zimfw action clean-modules to uninstall and have `zimfw clean` only do `clean-compiled` and `clean-dumpfile`. Semantically, it makes much more sense because we will be then cleaning temporary files that are later compiled/generated again, which is not the case for a module (which we'll be uninstalling now instead of cleaning). --- ...les.zsh.erb => 50_zimfw_uninstall.zsh.erb} | 4 +- src/stage2/80_zimfw.zsh.erb | 5 +-- zimfw.zsh | 37 +++++++++---------- 3 files changed, 22 insertions(+), 24 deletions(-) rename src/stage2/{49_zimfw_clean_modules.zsh.erb => 50_zimfw_uninstall.zsh.erb} (82%) diff --git a/src/stage2/49_zimfw_clean_modules.zsh.erb b/src/stage2/50_zimfw_uninstall.zsh.erb similarity index 82% rename from src/stage2/49_zimfw_clean_modules.zsh.erb rename to src/stage2/50_zimfw_uninstall.zsh.erb index a90c8c5..b470243 100644 --- a/src/stage2/49_zimfw_clean_modules.zsh.erb +++ b/src/stage2/50_zimfw_uninstall.zsh.erb @@ -1,4 +1,4 @@ -_zimfw_clean_modules() { +_zimfw_uninstall() { local zopt zdir zmodule (( ! _zquiet )) && zopt='-v' for zdir in ${ZIM_HOME}/modules/*(N/); do @@ -9,6 +9,6 @@ _zimfw_clean_modules() { fi done if (( ! _zquiet )); then - print -P '%F{green}✓%f Done with clean-modules.' + print -P '%F{green}✓%f Done with uninstall.' fi } diff --git a/src/stage2/80_zimfw.zsh.erb b/src/stage2/80_zimfw.zsh.erb index 9eec1cc..a7b0bef 100644 --- a/src/stage2/80_zimfw.zsh.erb +++ b/src/stage2/80_zimfw.zsh.erb @@ -5,12 +5,12 @@ Usage: %B${0}%b [%B-q%b] Actions: %Bbuild%b Build init.zsh %Bclean%b Clean all (see below) - %Bclean-modules%b Clean unused modules %Bclean-compiled%b Clean Zsh compiled files %Bclean-dumpfile%b Clean completion dump file %Bcompile%b Compile Zsh files %Binfo%b Print Zim and system info %Binstall%b Install new modules + %Buninstall%b Delete unused modules %Bupdate%b Update current modules %Bupgrade%b Upgrade <%= script_filename %> @@ -47,11 +47,9 @@ Options: init) _zimfw_source_zimrc && _zimfw_build ;; clean) _zimfw_source_zimrc && \ - _zimfw_clean_modules && \ _zimfw_clean_compiled && \ _zimfw_clean_dumpfile ;; - clean-modules) _zimfw_source_zimrc && _zimfw_clean_modules ;; clean-compiled) _zimfw_clean_compiled ;; clean-dumpfile) _zimfw_clean_dumpfile ;; compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;; @@ -64,6 +62,7 @@ Options: fi && \ _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;; + uninstall) _zimfw_source_zimrc && _zimfw_uninstall ;; upgrade) _zimfw_upgrade && _zimfw_compile ;; *) print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n'${zusage} diff --git a/zimfw.zsh b/zimfw.zsh index 4795413..40b0a96 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -234,21 +234,6 @@ _zimfw_source_zimrc() { fi } -_zimfw_clean_modules() { - local zopt zdir zmodule - (( ! _zquiet )) && 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 - fi - done - if (( ! _zquiet )); then - print -P '%F{green}✓%f Done with clean-modules.' - fi -} - _zimfw_clean_compiled() { local zopt_find zopt_rm zdir if (( ! _zquiet )); then @@ -279,12 +264,27 @@ _zimfw_clean_dumpfile() { } _zimfw_info() { - print 'Zim version: 1.0.0-SNAPSHOT (previous commit is 74404e6)' + print 'Zim version: 1.0.0-SNAPSHOT (previous commit is 69d609d)' 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 + (( ! _zquiet )) && 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 + fi + done + if (( ! _zquiet )); then + print -P '%F{green}✓%f Done with uninstall.' + fi +} + _zimfw_upgrade() { local -r zscript=${ZIM_HOME}/zimfw.zsh local -r zurl=https://raw.githubusercontent.com/zimfw/zimfw/develop/zimfw.zsh @@ -319,12 +319,12 @@ Usage: %B${0}%b [%B-q%b] Actions: %Bbuild%b Build init.zsh %Bclean%b Clean all (see below) - %Bclean-modules%b Clean unused modules %Bclean-compiled%b Clean Zsh compiled files %Bclean-dumpfile%b Clean completion dump file %Bcompile%b Compile Zsh files %Binfo%b Print Zim and system info %Binstall%b Install new modules + %Buninstall%b Delete unused modules %Bupdate%b Update current modules %Bupgrade%b Upgrade zimfw.zsh @@ -441,11 +441,9 @@ fi init) _zimfw_source_zimrc && _zimfw_build ;; clean) _zimfw_source_zimrc && \ - _zimfw_clean_modules && \ _zimfw_clean_compiled && \ _zimfw_clean_dumpfile ;; - clean-modules) _zimfw_source_zimrc && _zimfw_clean_modules ;; clean-compiled) _zimfw_clean_compiled ;; clean-dumpfile) _zimfw_clean_dumpfile ;; compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;; @@ -458,6 +456,7 @@ fi fi && \ _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;; + uninstall) _zimfw_source_zimrc && _zimfw_uninstall ;; upgrade) _zimfw_upgrade && _zimfw_compile ;; *) print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n'${zusage}