2019-01-22 19:40:43 -05:00
|
|
|
zimfw() {
|
2022-01-10 20:41:50 -05:00
|
|
|
builtin emulate -L zsh -o EXTENDED_GLOB
|
2023-03-24 09:40:55 -04:00
|
|
|
local -r _zversion='<%= version %>' _zversion_target=${ZIM_HOME}/.latest_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.
|
2023-02-25 19:03:37 -05:00
|
|
|
Also does %Bcompile%b. Use %B-v%b to also see its output.
|
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.
|
2022-10-23 20:34:14 -04:00
|
|
|
%Blist%b List all modules currently defined in %B${ZIM_CONFIG_FILE:-<%= home %>/.zimrc}%b.
|
2021-11-08 20:05:32 -05:00
|
|
|
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.
|
2023-02-25 19:03:37 -05:00
|
|
|
%Binstall%b Install new modules. Also does %Bbuild%b, %Bcompile%b. Use %B-v%b to also see their
|
|
|
|
output, any on-pull output and 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.
|
2023-03-26 10:34:07 -04:00
|
|
|
%Bcheck%b Check if updates for current modules are available. Use %B-v%b to also see
|
|
|
|
skipped and up to date modules.
|
2023-02-25 19:03:37 -05:00
|
|
|
%Bupdate%b Update current modules. Also does %Bbuild%b, %Bcompile%b. Use %B-v%b to also see their
|
|
|
|
output, any on-pull output and skipped modules.
|
2023-03-26 10:34:07 -04:00
|
|
|
%Bcheck-version%b Check if a new version of zimfw is available.
|
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:
|
2023-02-25 19:03:37 -05: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-09-26 21:33:49 -04:00
|
|
|
local -Ua _znames _zroot_dirs _zdisabled_root_dirs
|
2022-10-06 20:52:57 -04:00
|
|
|
local -A _zfrozens _ztools _zdirs _zurls _ztypes _zrevs _zsubmodules _zonpulls _zifs
|
2022-05-17 19:43:59 -04:00
|
|
|
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
|
|
|
|
|
2023-03-26 10:34:07 -04:00
|
|
|
if ! zstyle -t ':zim' disable-version-check && [[ ${1} != check-version ]]; then
|
2023-03-24 09:40:55 -04:00
|
|
|
# If .latest_version does not exist or was not modified in the last 30 days
|
|
|
|
[[ -f ${_zversion_target}(#qNm-30) ]]; local -r zversion_check_force=${?}
|
2023-06-16 21:24:33 -04:00
|
|
|
_zimfw_check_version ${zversion_check_force} 1
|
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-- ))
|
2023-02-25 19:03:37 -05:00
|
|
|
_zimfw_compile
|
2020-01-11 16:23:11 -05:00
|
|
|
;;
|
2023-02-25 19:03:37 -05:00
|
|
|
check-dumpfile) _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
|
|
|
;;
|
2023-03-26 10:34:07 -04:00
|
|
|
check)
|
|
|
|
_zrestartmsg=
|
2023-03-28 08:56:37 -04:00
|
|
|
_zimfw_run_tool_action ${1} || return 1
|
2023-03-26 10:34:07 -04:00
|
|
|
(( _zprintlevel-- ))
|
|
|
|
_zimfw_print -PR "<%= done %>Done with ${1}." # Only printed in verbose mode
|
|
|
|
;;
|
2022-01-10 09:29:32 -05:00
|
|
|
init)
|
|
|
|
_zrestartmsg=
|
2023-03-28 08:56:37 -04:00
|
|
|
_zimfw_run_tool_action install || return 1
|
2022-01-10 09:29:32 -05:00
|
|
|
(( _zprintlevel-- ))
|
2023-03-26 10:34:07 -04:00
|
|
|
_zimfw_print -PR "<%= done %>Done with install." # Only printed in verbose mode
|
2023-03-28 08:56:37 -04:00
|
|
|
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile
|
2022-01-10 09:29:32 -05:00
|
|
|
;;
|
2019-01-22 19:40:43 -05:00
|
|
|
install|update)
|
2023-03-28 08:56:37 -04:00
|
|
|
_zimfw_run_tool_action ${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-- ))
|
2023-03-28 08:56:37 -04:00
|
|
|
_zimfw_source_zimrc 2 && _zimfw_build && _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 ;;
|
2023-03-26 10:34:07 -04:00
|
|
|
check-version) _zimfw_check_version 1 ;;
|
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
|
|
|
|
}
|