26151d2f54
and replace the foreground color and bold expansions by ANSI escape codes. This should make the print calls now safe and no expansion at all should happen as we're using `-R` -- unless the `-e` flag is given. Fixes #521. Closes #522
106 lines
5.2 KiB
Plaintext
106 lines
5.2 KiB
Plaintext
zimfw() {
|
|
builtin emulate -L zsh -o EXTENDED_GLOB
|
|
local -r _zversion='<%= version %>' _zversion_target=${ZIM_HOME}/.latest_version zusage=$'Usage: <%= bold %>'${0}$'<%= normal %> <action> [<%= bold %>-q<%= normal %>|<%= bold %>-v<%= normal %>]
|
|
|
|
Actions:
|
|
<%= bold %>build<%= normal %> Build <%= bold %>'${ZIM_HOME}$'/init.zsh<%= normal %> and <%= bold %>'${ZIM_HOME}$'/login_init.zsh<%= normal %>.
|
|
Also does <%= bold %>compile<%= normal %>. Use <%= bold %>-v<%= normal %> to also see its output.
|
|
<%= bold %>clean<%= normal %> Clean all. Does both <%= bold %>clean-compiled<%= normal %> and <%= bold %>clean-dumpfile<%= normal %>.
|
|
<%= bold %>clean-compiled<%= normal %> Clean Zsh compiled files.
|
|
<%= bold %>clean-dumpfile<%= normal %> Clean completion dumpfile.
|
|
<%= bold %>compile<%= normal %> Compile Zsh files.
|
|
<%= bold %>help<%= normal %> Print this help.
|
|
<%= bold %>info<%= normal %> Print zimfw and system info.
|
|
<%= bold %>list<%= normal %> List all modules currently defined in <%= bold %>'${ZIM_CONFIG_FILE:-<%= home %>/.zimrc}$'<%= normal %>.
|
|
Use <%= bold %>-v<%= normal %> to also see the modules details.
|
|
<%= bold %>init<%= normal %> Same as <%= bold %>install<%= normal %>, but with output tailored to be used at terminal startup.
|
|
<%= bold %>install<%= normal %> Install new modules. Also does <%= bold %>build<%= normal %>, <%= bold %>compile<%= normal %>. Use <%= bold %>-v<%= normal %> to also see their
|
|
output, any on-pull output and skipped modules.
|
|
<%= bold %>uninstall<%= normal %> Delete unused modules. Prompts for confirmation. Use <%= bold %>-q<%= normal %> for quiet uninstall.
|
|
<%= bold %>check<%= normal %> Check if updates for current modules are available. Use <%= bold %>-v<%= normal %> to also see
|
|
skipped and up to date modules.
|
|
<%= bold %>update<%= normal %> Update current modules. Also does <%= bold %>build<%= normal %>, <%= bold %>compile<%= normal %>. Use <%= bold %>-v<%= normal %> to also see their
|
|
output, any on-pull output and skipped modules.
|
|
<%= bold %>check-version<%= normal %> Check if a new version of zimfw is available.
|
|
<%= bold %>upgrade<%= normal %> Upgrade zimfw. Also does <%= bold %>compile<%= normal %>. Use <%= bold %>-v<%= normal %> to also see its output.
|
|
<%= bold %>version<%= normal %> Print zimfw version.
|
|
|
|
Options:
|
|
<%= bold %>-q<%= normal %> Quiet (yes to prompts and only outputs errors)
|
|
<%= bold %>-v<%= normal %> Verbose (outputs more details)'
|
|
local -Ua _znames _zroot_dirs _zdisabled_root_dirs
|
|
local -A _zfrozens _ztools _zdirs _zurls _ztypes _zrevs _zsubmodules _zonpulls _zifs
|
|
local -a _zfpaths _zfunctions _zcmds _zunused_dirs
|
|
local -i _zprintlevel=1
|
|
if (( # > 2 )); then
|
|
print -u2 -lR $'<%= red %>'${0}$': Too many options<%= normal %>' '' ${zusage}
|
|
return 2
|
|
elif (( # > 1 )); then
|
|
case ${2} in
|
|
-q) _zprintlevel=0 ;;
|
|
-v) _zprintlevel=2 ;;
|
|
*)
|
|
print -u2 -lR $'<%= red %>'${0}': Unknown option '${2}$'<%= normal %>' '' ${zusage}
|
|
return 2
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
if ! zstyle -t ':zim' disable-version-check && [[ ${1} != check-version ]]; then
|
|
# 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=${?}
|
|
_zimfw_check_version ${zversion_check_force} 1
|
|
fi
|
|
|
|
local _zrestartmsg=' Restart your terminal for changes to take effect.'
|
|
case ${1} in
|
|
build)
|
|
_zimfw_source_zimrc 2 && _zimfw_build || return 1
|
|
(( _zprintlevel-- ))
|
|
_zimfw_compile
|
|
;;
|
|
check-dumpfile) _zimfw_check_dumpfile ;;
|
|
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_compile ;;
|
|
help) print -R ${zusage} ;;
|
|
info) _zimfw_info ;;
|
|
list)
|
|
_zimfw_source_zimrc 3 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \
|
|
_zimfw_list_unuseds ' (unused)'
|
|
;;
|
|
check)
|
|
_zrestartmsg=
|
|
_zimfw_run_tool_action ${1} || return 1
|
|
(( _zprintlevel-- ))
|
|
_zimfw_print -R "Done with ${1}." # Only printed in verbose mode
|
|
;;
|
|
init)
|
|
_zrestartmsg=
|
|
_zimfw_run_tool_action install || return 1
|
|
(( _zprintlevel-- ))
|
|
_zimfw_print 'Done with install.' # Only printed in verbose mode
|
|
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile
|
|
;;
|
|
install|update)
|
|
_zimfw_run_tool_action ${1} || return 1
|
|
_zimfw_print -R "Done with ${1}.${_zrestartmsg}"
|
|
(( _zprintlevel-- ))
|
|
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile
|
|
;;
|
|
uninstall) _zimfw_source_zimrc 2 && _zimfw_list_unuseds && _zimfw_uninstall ;;
|
|
check-version) _zimfw_check_version 1 ;;
|
|
upgrade)
|
|
_zimfw_upgrade || return 1
|
|
(( _zprintlevel-- ))
|
|
_zimfw_source_zimrc 2 && _zimfw_compile
|
|
;;
|
|
version) print -R ${_zversion} ;;
|
|
*)
|
|
print -u2 -lR $'<%= red %>'${0}': Unknown action '${1}$'<%= normal %>' '' ${zusage}
|
|
return 2
|
|
;;
|
|
esac
|
|
}
|