zimfw/src/stage2/80_zimfw.zsh.erb

78 lines
3.0 KiB
Plaintext

zimfw() {
local -r _zversion='<%= version %>' zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
Actions:
%Bbuild%b Build %B${ZIM_HOME}/init.zsh%b and %B${ZIM_HOME}/login_init.zsh%b.
Also does %Bcompile%b. Use %B-v%b to also see its output.
%Bclean%b Clean all. Does both %Bclean-compiled%b and %Bclean-dumpfile%b.
%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.
%Blist%b List all modules. Use %B-v%b to also see the current details for all modules.
%Binstall%b Install new modules. Also does %Bbuild%b, %Bcompile%b. Use %B-v%b to also see their output.
%Buninstall%b Delete unused modules. Prompts for confirmation. Use %B-q%b to uninstall quietly.
%Bupdate%b Update current modules. Also does %Bbuild%b, %Bcompile%b. Use %B-v%b to see their output.
%Bupgrade%b Upgrade zimfw. Also does %Bcompile%b. Use %B-v%b to also see its output.
%Bversion%b Print zimfw version.
Options:
%B-q%b Quiet (yes to prompts, and only outputs errors)
%B-v%b Verbose (outputs more details)"
local -a _zdisabled_dirs _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs _zunused_dirs
local -i _zprintlevel=1
if (( # > 2 )); then
print -u2 -PRl "%F{red}${0}: Too many options%f" '' ${zusage}
return 2
elif (( # > 1 )); then
case ${2} in
-q) _zprintlevel=0 ;;
-v) _zprintlevel=2 ;;
*)
print -u2 -PRl "%F{red}${0}: Unknown option ${2}%f" '' ${zusage}
return 2
;;
esac
fi
if ! zstyle -t ':zim' disable-version-check; then
_zimfw_version_check
fi
case ${1} in
build)
_zimfw_source_zimrc 2 && _zimfw_build || return 1
(( _zprintlevel-- ))
_zimfw_compile
;;
init) _zimfw_install_update install && _zimfw_source_zimrc 2 && _zimfw_build ;;
clean) _zimfw_source_zimrc 2 && _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
clean-compiled) _zimfw_source_zimrc 2 && _zimfw_clean_compiled ;;
clean-dumpfile) _zimfw_clean_dumpfile ;;
compile) _zimfw_source_zimrc 2 && _zimfw_build_login_init && _zimfw_compile ;;
help) print -PR ${zusage} ;;
info) _zimfw_info ;;
list)
_zimfw_source_zimrc 3 && zargs -n 9 -- "${_zmodules_zargs[@]}" -- _zimfw_run_list && \
_zimfw_list_unuseds ' (unused)'
;;
install|update)
_zimfw_install_update ${1} || return 1
(( _zprintlevel-- ))
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile
;;
uninstall) _zimfw_source_zimrc 2 && _zimfw_list_unuseds && _zimfw_uninstall ;;
upgrade)
_zimfw_upgrade || return 1
(( _zprintlevel-- ))
_zimfw_compile
;;
version) print -PR ${_zversion} ;;
*)
print -u2 -PRl "%F{red}${0}: Unknown action ${1}%f" '' ${zusage}
return 2
;;
esac
}