1
0
Fork 0
mirror of synced 2024-06-07 17:41:10 -04:00
zimfw/src/stage2/80_zimfw.zsh.erb
Eric Nielsen cffd456556
Add new degit tool \o/
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
2021-04-07 17:54:47 -05:00

77 lines
2.5 KiB
Plaintext

zimfw() {
local -r _zversion='<%= version %>'
local -r zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
Actions:
%Bbuild%b Build %Binit.zsh%b and %Blogin_init.zsh%b
%Bclean%b Clean all (see below)
%Bclean-compiled%b Clean Zsh compiled files
%Bclean-dumpfile%b Clean completion dump file
%Bcompile%b Compile Zsh files
%Bhelp%b Print this help
%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 %Bzimfw.zsh%b
%Bversion%b Print Zim version
Options:
%B-q%b Quiet (yes to prompts, and only outputs errors)
%B-v%b Verbose
"
local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs
local -i _zprintlevel=1
if (( # > 2 )); then
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}
return 2
elif (( # > 1 )); then
case ${2} in
-q) _zprintlevel=0 ;;
-v) _zprintlevel=2 ;;
*)
print -u2 -PR "%F{red}${0}: Unknown option ${2}%f"$'\n\n'${zusage}
return 2
;;
esac
fi
if ! zstyle -t ':zim' disable-version-check; then
_zimfw_version_check
fi
case ${1} in
build)
_zimfw_source_zimrc && _zimfw_build || return 1
(( _zprintlevel-- ))
_zimfw_compile
;;
init) _zimfw_source_zimrc && _zimfw_build ;;
clean) _zimfw_source_zimrc && _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
clean-compiled) _zimfw_source_zimrc && _zimfw_clean_compiled ;;
clean-dumpfile) _zimfw_clean_dumpfile ;;
compile) _zimfw_source_zimrc && _zimfw_build_login_init && _zimfw_compile ;;
help) print -PR ${zusage} ;;
info) _zimfw_info ;;
install|update)
_zimfw_source_zimrc ${1} || return 1
autoload -Uz zargs && \
zargs -n 7 -P 10 -- "${_zmodules_zargs[@]}" -- _zimfw_run_tool && \
_zimfw_print -PR "<%= done %>Done with ${1}. Restart your terminal for any changes to take effect." || return 1
(( _zprintlevel-- ))
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile
;;
uninstall) _zimfw_source_zimrc && _zimfw_uninstall ;;
upgrade)
_zimfw_upgrade || return 1
(( _zprintlevel-- ))
_zimfw_compile
;;
version) print -PR ${_zversion} ;;
*)
print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n\n'${zusage}
return 2
;;
esac
}