2019-01-22 19:40:43 -05:00
|
|
|
zimfw() {
|
2022-01-10 20:41:50 -05:00
|
|
|
builtin emulate -L zsh -o EXTENDED_GLOB
|
2021-07-11 16:58:15 -04:00
|
|
|
local -r _zversion='<%= version %>' zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
|
2019-01-22 19:40:43 -05:00
|
|
|
|
2019-12-01 16:00:47 -05:00
|
|
|
Actions:
|
2021-09-21 09:27:56 -04:00
|
|
|
%Bbuild%b Build %B${ZIM_HOME}/init.zsh%b and %B${ZIM_HOME}/login_init.zsh%b.
|
2022-01-18 20:34:36 -05:00
|
|
|
Also does %Bcheck-dumpfile%b and %Bcompile%b. Use %B-v%b to also see their output.
|
|
|
|
%Bcheck-dumpfile%b Does %Bclean-dumpfile%b if new completion configuration needs to be dumped.
|
2021-09-21 09:27:56 -04:00
|
|
|
%Bclean%b Clean all. Does both %Bclean-compiled%b and %Bclean-dumpfile%b.
|
|
|
|
%Bclean-compiled%b Clean Zsh compiled files.
|
2022-01-18 20:34:36 -05:00
|
|
|
%Bclean-dumpfile%b Clean completion dumpfile.
|
2021-09-21 09:27:56 -04:00
|
|
|
%Bcompile%b Compile Zsh files.
|
|
|
|
%Bhelp%b Print this help.
|
|
|
|
%Binfo%b Print Zim and system info.
|
2021-11-08 20:05:32 -05:00
|
|
|
%Blist%b List all modules currently defined in %B<%= home %>/.zimrc%b.
|
|
|
|
Use %B-v%b to also see the modules details.
|
2022-01-10 09:29:32 -05:00
|
|
|
%Binit%b Same as %Binstall%b, but with output tailored to be used at terminal startup.
|
2022-01-18 20:34:36 -05:00
|
|
|
%Binstall%b Install new modules. Also does %Bbuild%b, %Bcheck-dumpfile%b and %Bcompile%b. Use %B-v%b to
|
2022-05-07 17:31:08 -04:00
|
|
|
also see their output, any on-pull output, and see skipped modules.
|
2021-11-15 19:37:40 -05:00
|
|
|
%Buninstall%b Delete unused modules. Prompts for confirmation. Use %B-q%b for quiet uninstall.
|
2022-01-18 20:34:36 -05:00
|
|
|
%Bupdate%b Update current modules. Also does %Bbuild%b, %Bcheck-dumpfile%b and %Bcompile%b. Use %B-v%b
|
2022-05-07 17:31:08 -04:00
|
|
|
to also see their output, any on-pull output, and see skipped modules.
|
2021-09-21 09:27:56 -04:00
|
|
|
%Bupgrade%b Upgrade zimfw. Also does %Bcompile%b. Use %B-v%b to also see its output.
|
|
|
|
%Bversion%b Print zimfw version.
|
2019-12-01 16:00:47 -05:00
|
|
|
|
|
|
|
Options:
|
2021-09-21 17:36:32 -04:00
|
|
|
%B-q%b Quiet (yes to prompts, and only outputs errors)
|
2021-09-21 09:27:56 -04:00
|
|
|
%B-v%b Verbose (outputs more details)"
|
2022-05-17 19:43:59 -04:00
|
|
|
local -Ua _znames _zdisabled_dirs
|
|
|
|
local -A _zfrozens _zdisableds _ztools _zdirs _zurls _ztypes _zrevs _zsubmodules _zonpulls
|
|
|
|
local -a _zfpaths _zfunctions _zcmds _zunused_dirs
|
2020-01-11 16:23:11 -05:00
|
|
|
local -i _zprintlevel=1
|
2019-12-01 16:00:47 -05:00
|
|
|
if (( # > 2 )); then
|
2021-11-08 11:38:56 -05:00
|
|
|
print -u2 -PlR "%F{red}${0}: Too many options%f" '' ${zusage}
|
2021-03-19 18:13:21 -04:00
|
|
|
return 2
|
2019-12-01 16:00:47 -05:00
|
|
|
elif (( # > 1 )); then
|
|
|
|
case ${2} in
|
2020-01-11 16:23:11 -05:00
|
|
|
-q) _zprintlevel=0 ;;
|
|
|
|
-v) _zprintlevel=2 ;;
|
2019-12-01 16:00:47 -05:00
|
|
|
*)
|
2021-11-08 11:38:56 -05:00
|
|
|
print -u2 -PlR "%F{red}${0}: Unknown option ${2}%f" '' ${zusage}
|
2021-03-19 18:13:21 -04:00
|
|
|
return 2
|
2019-12-01 16:00:47 -05:00
|
|
|
;;
|
|
|
|
esac
|
2019-01-22 19:40:43 -05:00
|
|
|
fi
|
|
|
|
|
2020-01-15 12:35:30 -05:00
|
|
|
if ! zstyle -t ':zim' disable-version-check; then
|
|
|
|
_zimfw_version_check
|
2020-01-13 13:14:31 -05:00
|
|
|
fi
|
|
|
|
|
2022-01-10 09:29:32 -05:00
|
|
|
local _zrestartmsg=' Restart your terminal for changes to take effect.'
|
2019-01-22 19:40:43 -05:00
|
|
|
case ${1} in
|
2020-01-11 16:23:11 -05:00
|
|
|
build)
|
2021-09-19 14:37:13 -04:00
|
|
|
_zimfw_source_zimrc 2 && _zimfw_build || return 1
|
2020-01-11 16:23:11 -05:00
|
|
|
(( _zprintlevel-- ))
|
2022-01-18 20:34:36 -05:00
|
|
|
_zimfw_check_dumpfile && _zimfw_compile
|
2020-01-11 16:23:11 -05:00
|
|
|
;;
|
2022-01-18 20:34:36 -05:00
|
|
|
check-dumpfile) _zimfw_source_zimrc 2 && _zimfw_check_dumpfile ;;
|
2021-09-19 14:37:13 -04:00
|
|
|
clean) _zimfw_source_zimrc 2 && _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
|
|
|
clean-compiled) _zimfw_source_zimrc 2 && _zimfw_clean_compiled ;;
|
2019-12-01 16:00:47 -05:00
|
|
|
clean-dumpfile) _zimfw_clean_dumpfile ;;
|
2022-05-17 19:43:59 -04:00
|
|
|
compile) _zimfw_source_zimrc 2 && _zimfw_compile ;;
|
2020-01-13 13:14:31 -05:00
|
|
|
help) print -PR ${zusage} ;;
|
2019-12-01 16:00:47 -05:00
|
|
|
info) _zimfw_info ;;
|
2021-09-19 14:37:13 -04:00
|
|
|
list)
|
2022-05-17 19:43:59 -04:00
|
|
|
_zimfw_source_zimrc 3 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \
|
2021-09-29 22:22:28 -04:00
|
|
|
_zimfw_list_unuseds ' (unused)'
|
2021-09-19 14:37:13 -04:00
|
|
|
;;
|
2022-01-10 09:29:32 -05:00
|
|
|
init)
|
|
|
|
_zrestartmsg=
|
|
|
|
_zimfw_install_update install || return 1
|
|
|
|
(( _zprintlevel-- ))
|
|
|
|
_zimfw_print -PR "<%= done %>Done with install.${_zrestartmsg}" # Only printed in verbose mode
|
2022-01-18 20:34:36 -05:00
|
|
|
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_check_dumpfile && _zimfw_compile
|
2022-01-10 09:29:32 -05:00
|
|
|
;;
|
2019-01-22 19:40:43 -05:00
|
|
|
install|update)
|
2021-10-26 12:15:40 -04:00
|
|
|
_zimfw_install_update ${1} || return 1
|
2022-01-10 09:29:32 -05:00
|
|
|
_zimfw_print -PR "<%= done %>Done with ${1}.${_zrestartmsg}"
|
2020-01-11 16:23:11 -05:00
|
|
|
(( _zprintlevel-- ))
|
2022-01-18 20:34:36 -05:00
|
|
|
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_check_dumpfile && _zimfw_compile
|
2019-01-22 19:40:43 -05:00
|
|
|
;;
|
2021-09-19 14:37:13 -04:00
|
|
|
uninstall) _zimfw_source_zimrc 2 && _zimfw_list_unuseds && _zimfw_uninstall ;;
|
2020-01-11 16:23:11 -05:00
|
|
|
upgrade)
|
|
|
|
_zimfw_upgrade || return 1
|
|
|
|
(( _zprintlevel-- ))
|
2022-05-17 19:43:59 -04:00
|
|
|
_zimfw_source_zimrc 2 && _zimfw_compile
|
2020-01-11 16:23:11 -05:00
|
|
|
;;
|
2020-01-13 13:14:31 -05:00
|
|
|
version) print -PR ${_zversion} ;;
|
2019-01-22 19:40:43 -05:00
|
|
|
*)
|
2021-11-08 11:38:56 -05:00
|
|
|
print -u2 -PlR "%F{red}${0}: Unknown action ${1}%f" '' ${zusage}
|
2021-03-19 18:13:21 -04:00
|
|
|
return 2
|
2019-01-22 19:40:43 -05:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|