1
0
Fork 0
mirror of synced 2024-06-23 08:51:10 -04:00
zimfw/src/stage2/70_zimfw_run_tool.zsh.erb
Eric Nielsen de7d2b131f
More verbose output in install and update actions
listing modules that are frozen or exernal.

Also be less colorful. And some other minor fixes: allow autoloading a
function name that starts with `-`, and add required quotes around
command subsitution (otherwise words are split).
2021-09-29 21:22:28 -05:00

42 lines
1.3 KiB
Plaintext

_zimfw_run_tool() {
local -r ztool=${1} zaction=${2} zmodule=${3} zdir=${4} zurl=${5}
if [[ -z ${zurl} ]]; then
if (( _zprintlevel > 1 )) print -u2 -PR <%= clear_line %>"<%= okay %>%B${zmodule}:%b Skipping external module"
return 0
fi
local -ri zfrozen=${8}
if (( zfrozen )); then
if (( _zprintlevel > 1 )) print -u2 -PR <%= clear_line %>"<%= okay %>%B${zmodule}:%b Skipping frozen module"
return 0
fi
case ${zaction} in
install)
if [[ -e ${zdir} ]]; then
# Already installed
return 0
fi
_zimfw_print -Rn <%= clear_line %>"Installing ${zmodule}<%= ellipsis %>"
;;
update)
if [[ ! -d ${zdir} ]]; then
print -u2 -PR <%= clear_line %>"%F{red}<%= error %>%B${zmodule}:%b Not installed. Run %Bzimfw install%b to install.%f"
return 1
fi
_zimfw_print -Rn <%= clear_line %>"Updating ${zmodule}<%= ellipsis %>"
;;
*)
print -u2 -PR <%= clear_line %>"%F{red}<%= error %>%B${zmodule}:%b Unknown action ${zaction}%f"
return 1
;;
esac
local zcmd
case ${ztool} in
<%= render_tools("src/tools/*", "zcmd") %>
*)
print -u2 -PR "<%= clear_line %>%F{red}<%= error %>%B${zmodule}:%b Unknown tool ${ztool}%f"
return 1
;;
esac
zsh -c ${zcmd} ${ztool} ${_zprintlevel} "${@[2,7]}"
}