From e9279aaa5366a4fd751c50173237ba74e807ac41 Mon Sep 17 00:00:00 2001 From: Eric Nielsen <4120606+ericbn@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:42:58 -0500 Subject: [PATCH] Use just one flag when zmodule should be eager and then assume that the module is already installed. Was using bitwise flags before, which was unnecessarily complex. --- src/functions/30_zmodule.zsh.erb | 6 ++---- src/stage2/31_zimfw_source_zimrc.zsh.erb | 4 ++-- src/stage2/78_zimfw_run_tool_action.zsh.erb | 2 +- src/stage2/80_zimfw.zsh.erb | 8 +++---- src/zimfw.zsh.erb | 2 +- zimfw.zsh | 24 ++++++++++----------- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/functions/30_zmodule.zsh.erb b/src/functions/30_zmodule.zsh.erb index a5142b6..af92293 100644 --- a/src/functions/30_zmodule.zsh.erb +++ b/src/functions/30_zmodule.zsh.erb @@ -206,10 +206,8 @@ Per-call initialization options: esac shift done - if (( _zflags & 1 )); then - _znames+=(${zname}) - fi - if (( _zflags & 2 )); then + _znames+=(${zname}) + if (( _zeager )); then if [[ ! -e ${zroot_dir} ]]; then print -u2 -R "${_zerror}${funcfiletrace[1]}:${_zbold}${zname}: ${zroot_dir}${_znormalred} not found${_znormal}" _zfailed=1 diff --git a/src/stage2/31_zimfw_source_zimrc.zsh.erb b/src/stage2/31_zimfw_source_zimrc.zsh.erb index ded2ada..eecae85 100644 --- a/src/stage2/31_zimfw_source_zimrc.zsh.erb +++ b/src/stage2/31_zimfw_source_zimrc.zsh.erb @@ -1,13 +1,13 @@ _zimfw_source_zimrc() { <%= render_all("src/functions/*.erb") %> { - local -r _zflags=${1} + local -ri _zeager=${1} local -i _zfailed=0 if ! source ${_zconfig} || (( _zfailed )); then print -u2 -R "${_zred}Failed to source ${_zbold}${_zconfig}${_znormal}" return 1 fi - if (( _zflags & 1 && ${#_znames} == 0 )); then + if (( ${#_znames} == 0 )); then print -u2 -R "${_zred}No modules defined in ${_zbold}${_zconfig}${_znormal}" return 1 fi diff --git a/src/stage2/78_zimfw_run_tool_action.zsh.erb b/src/stage2/78_zimfw_run_tool_action.zsh.erb index d51e69a..5feb081 100644 --- a/src/stage2/78_zimfw_run_tool_action.zsh.erb +++ b/src/stage2/78_zimfw_run_tool_action.zsh.erb @@ -1,7 +1,7 @@ _zimfw_run_tool_action() { local -i zmaxprocs=0 if [[ ${1} == reinstall ]] zmaxprocs=1 - _zimfw_source_zimrc 1 || return 1 + _zimfw_source_zimrc 0 || return 1 zargs -n 2 -P ${zmaxprocs} -- "${_znames[@]}" -- _zimfw_run_tool ${1} return 0 } diff --git a/src/stage2/80_zimfw.zsh.erb b/src/stage2/80_zimfw.zsh.erb index fe510c3..8bf7ee9 100644 --- a/src/stage2/80_zimfw.zsh.erb +++ b/src/stage2/80_zimfw.zsh.erb @@ -72,7 +72,7 @@ Options: local _zrestartmsg=' Restart your terminal for changes to take effect.' case ${1} in build) - _zimfw_source_zimrc 2 && _zimfw_build || return 1 + _zimfw_source_zimrc 1 && _zimfw_build || return 1 (( _zprintlevel-- )) _zimfw_compile ;; @@ -84,7 +84,7 @@ Options: help) print -R ${zusage} ;; info) _zimfw_info ;; list) - _zimfw_source_zimrc 3 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \ + _zimfw_source_zimrc 1 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \ _zimfw_list_unuseds ' (unused)' ;; check) @@ -98,13 +98,13 @@ Options: _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 + _zimfw_source_zimrc 1 && _zimfw_build && _zimfw_compile ;; install|update|reinstall) _zimfw_run_tool_action ${1} || return 1 _zimfw_print -R "Done with ${1}.${_zrestartmsg}" (( _zprintlevel-- )) - _zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile + _zimfw_source_zimrc 1 && _zimfw_build && _zimfw_compile ;; uninstall) _zimfw_source_zimrc 0 && _zimfw_list_unuseds && _zimfw_uninstall ;; check-version) _zimfw_check_version 1 ;; diff --git a/src/zimfw.zsh.erb b/src/zimfw.zsh.erb index 9b19fdd..e9cacf8 100644 --- a/src/zimfw.zsh.erb +++ b/src/zimfw.zsh.erb @@ -4,7 +4,7 @@ class Zim :bold, :normal, :red, :normalred, :yellow, :normalyellow, :clear_line, :ellipsis, :okay, :warn, :error def initialize - @version = "1.16.0" + @version = "1.17.0-SNAPSHOT" @home = "${ZDOTDIR:-${HOME}}" @min_zsh_version = "5.2" # Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo diff --git a/zimfw.zsh b/zimfw.zsh index 77a83b2..2d5d2d3 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -325,10 +325,8 @@ Per-call initialization options: esac shift done - if (( _zflags & 1 )); then - _znames+=(${zname}) - fi - if (( _zflags & 2 )); then + _znames+=(${zname}) + if (( _zeager )); then if [[ ! -e ${zroot_dir} ]]; then print -u2 -R "${_zerror}${funcfiletrace[1]}:${_zbold}${zname}: ${zroot_dir}${_znormalred} not found${_znormal}" _zfailed=1 @@ -362,13 +360,13 @@ Per-call initialization options: } { - local -r _zflags=${1} + local -ri _zeager=${1} local -i _zfailed=0 if ! source ${_zconfig} || (( _zfailed )); then print -u2 -R "${_zred}Failed to source ${_zbold}${_zconfig}${_znormal}" return 1 fi - if (( _zflags & 1 && ${#_znames} == 0 )); then + if (( ${#_znames} == 0 )); then print -u2 -R "${_zred}No modules defined in ${_zbold}${_zconfig}${_znormal}" return 1 fi @@ -470,7 +468,7 @@ _zimfw_info() { _zimfw_info_print_symlink ZIM_HOME ${ZIM_HOME} _zimfw_info_print_symlink 'zimfw config' ${_zconfig} _zimfw_info_print_symlink 'zimfw script' ${__ZIMFW_FILE} - print -R 'zimfw version: '${_zversion}' (built at 2024-11-25 13:50:33 UTC, previous commit is 2d5718e)' + print -R 'zimfw version: '${_zversion}' (built at 2024-11-27 23:41:51 UTC, previous commit is 923014a)' local zparam for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZSH_VERSION; do print -R ${(r.22....:.)zparam}${(P)zparam} @@ -952,7 +950,7 @@ _zimfw_run_tool() { _zimfw_run_tool_action() { local -i zmaxprocs=0 if [[ ${1} == reinstall ]] zmaxprocs=1 - _zimfw_source_zimrc 1 || return 1 + _zimfw_source_zimrc 0 || return 1 zargs -n 2 -P ${zmaxprocs} -- "${_znames[@]}" -- _zimfw_run_tool ${1} return 0 } @@ -965,7 +963,7 @@ zimfw() { local -r _znormal= _zbold= _zred= _znormalred= _zgreen= _zyellow= _znormalyellow= fi local -r _zerror="${_zred}x " _zokay="${_zgreen}) ${_znormal}" _zwarn="${_zyellow}! " - local -r _zconfig=${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} _zversion='1.16.0' + local -r _zconfig=${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} _zversion='1.17.0-SNAPSHOT' local -r zusage="Usage: ${_zbold}${0}${_znormal} [${_zbold}-q${_znormal}|${_zbold}-v${_znormal}] Actions: @@ -1031,7 +1029,7 @@ Options: local _zrestartmsg=' Restart your terminal for changes to take effect.' case ${1} in build) - _zimfw_source_zimrc 2 && _zimfw_build || return 1 + _zimfw_source_zimrc 1 && _zimfw_build || return 1 (( _zprintlevel-- )) _zimfw_compile ;; @@ -1043,7 +1041,7 @@ Options: help) print -R ${zusage} ;; info) _zimfw_info ;; list) - _zimfw_source_zimrc 3 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \ + _zimfw_source_zimrc 1 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \ _zimfw_list_unuseds ' (unused)' ;; check) @@ -1057,13 +1055,13 @@ Options: _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 + _zimfw_source_zimrc 1 && _zimfw_build && _zimfw_compile ;; install|update|reinstall) _zimfw_run_tool_action ${1} || return 1 _zimfw_print -R "Done with ${1}.${_zrestartmsg}" (( _zprintlevel-- )) - _zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile + _zimfw_source_zimrc 1 && _zimfw_build && _zimfw_compile ;; uninstall) _zimfw_source_zimrc 0 && _zimfw_list_unuseds && _zimfw_uninstall ;; check-version) _zimfw_check_version 1 ;;