cffd456556
and rename previous to git. Tools allow for different install and update scripts. The git tool does what the previous implementation did (installs and updates using the git client). The new tool installs and updates with the GitHub API, not using the git client, but using curl/wget and tar instead. Closes #373
38 lines
995 B
Plaintext
38 lines
995 B
Plaintext
_zimfw_run_tool() {
|
|
local -r ztool=${1}
|
|
shift
|
|
local -r zaction=${1}
|
|
local -r zmodule=${2}
|
|
local -r zdir=${3}
|
|
local -r clear_line=<%= clear_line %>
|
|
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 "%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 "%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 "%F{red}<%= error %>%B${zmodule}:%b Unknown tool ${ztool}%f"
|
|
return 1
|
|
;;
|
|
esac
|
|
zsh -c ${zcmd} ${ztool} "${@}" ${_zprintlevel}
|
|
}
|