36 lines
1.0 KiB
Plaintext
36 lines
1.0 KiB
Plaintext
_zimfw_run_tool() {
|
|
local -ri zfrozen=${8}
|
|
if (( zfrozen )) return 0
|
|
local -r ztool=${1} zaction=${2} zmodule=${3} zdir=${4} zurl=${5}
|
|
if [[ -z ${zurl} ]] return 0
|
|
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]}"
|
|
}
|