Override repository options along zmodule calls
for the same module name. Other minor fixes:
* Show skipping already installed modules with install action and `-v`.
* Consider external module dirs when calling compile action directly, by
making sure _zimfw_source_zimrc is called first.
* Ignore return value from `zargs` with `-P`, as it's oddly returning
123 since Zsh 5.9. Maybe related to these changes:
67f932e7c5
This commit is contained in:
parent
d6b4aa6ff4
commit
5bcfb8cc9f
13 changed files with 195 additions and 182 deletions
|
@ -7,7 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
_No unreleased changes._
|
||||
### Fixed
|
||||
|
||||
- Calling `zmodule` more than once will override the repository options along
|
||||
the calls for the same module name.
|
||||
- Also show skipping already installed modules with the install action and `-v`.
|
||||
- Also consider external module directory paths when calling the compile action
|
||||
directly.
|
||||
- Ignore return value from `zargs` with `-P`.
|
||||
|
||||
## [1.9.0] - 2022-05-09
|
||||
|
||||
|
|
|
@ -52,12 +52,10 @@ Initialization options:
|
|||
_zfailed=1
|
||||
return 2
|
||||
fi
|
||||
local zurl=${1} zmodule=${1:t} ztool zdir ztype zrev zarg
|
||||
local -i zsubmodules=1 zfrozen=0 zdisabled=0
|
||||
local -a zonpulls zfpaths zfunctions zcmds
|
||||
zstyle -s ':zim:zmodule' use 'ztool' || ztool=git
|
||||
local zurl=${1} zname=${1:t} zarg
|
||||
local -a zfpaths zfunctions zcmds
|
||||
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
||||
zmodule=${zmodule%.git}
|
||||
zname=${zname%.git}
|
||||
elif [[ ${zurl} != /* ]]; then
|
||||
# Count number of slashes
|
||||
case ${#zurl//[^\/]/} in
|
||||
|
@ -66,27 +64,35 @@ Initialization options:
|
|||
esac
|
||||
fi
|
||||
shift
|
||||
if [[ ${1} == (-n|--name) ]]; then
|
||||
while [[ ${1} == (-n|--name) ]]; do
|
||||
if (( # < 2 )); then
|
||||
print -u2 -PlR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option %B${1}%b%f" '' ${zusage}
|
||||
print -u2 -PlR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zname}:%b Missing argument for zmodule option %B${1}%b%f" '' ${zusage}
|
||||
_zfailed=1
|
||||
return 2
|
||||
fi
|
||||
shift
|
||||
zmodule=${${1%%/##}##/##}
|
||||
zname=${${1%%/##}##/##}
|
||||
shift
|
||||
fi
|
||||
done
|
||||
if [[ ${zurl} == /* ]]; then
|
||||
zdir=${zurl%%/##}
|
||||
_zdirs[${zname}]=${zurl%%/##}
|
||||
zurl=
|
||||
else
|
||||
zdir=${ZIM_HOME}/modules/${zmodule}
|
||||
_zdirs[${zname}]=${ZIM_HOME}/modules/${zname}
|
||||
fi
|
||||
_zurls[${zname}]=${zurl}
|
||||
# Set default values
|
||||
if (( ! ${+_ztools[${zname}]} )); then
|
||||
zstyle -s ':zim:zmodule' use "_ztools[${zname}]" || _ztools[${zname}]=git
|
||||
fi
|
||||
if (( ! ${+_ztypes[${zname}]} )) _ztypes[${zname}]=branch
|
||||
if (( ! ${+_zsubmodules[${zname}]} )) _zsubmodules[${zname}]=1
|
||||
# Set values from options
|
||||
while (( # > 0 )); do
|
||||
case ${1} in
|
||||
-b|--branch|-t|--tag|-u|--use|--on-pull|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
|
||||
if (( # < 2 )); then
|
||||
print -u2 -PlR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option %B${1}%b%f" '' ${zusage}
|
||||
print -u2 -PlR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zname}:%b Missing argument for zmodule option %B${1}%b%f" '' ${zusage}
|
||||
_zfailed=1
|
||||
return 2
|
||||
fi
|
||||
|
@ -94,34 +100,34 @@ Initialization options:
|
|||
esac
|
||||
case ${1} in
|
||||
-b|--branch|-t|--tag|-u|--use|--no-submodules)
|
||||
if [[ -z ${zurl} ]] _zimfw_print -u2 -PR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b The zmodule option %B${1}%b has no effect for external modules%f"
|
||||
if [[ -z ${zurl} ]] _zimfw_print -u2 -PR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zname}:%b The zmodule option %B${1}%b has no effect for external modules%f"
|
||||
;;
|
||||
esac
|
||||
case ${1} in
|
||||
-b|--branch)
|
||||
shift
|
||||
ztype=branch
|
||||
zrev=${1}
|
||||
_ztypes[${zname}]=branch
|
||||
_zrevs[${zname}]=${1}
|
||||
;;
|
||||
-t|--tag)
|
||||
shift
|
||||
ztype=tag
|
||||
zrev=${1}
|
||||
_ztypes[${zname}]=tag
|
||||
_zrevs[${zname}]=${1}
|
||||
;;
|
||||
-u|--use)
|
||||
shift
|
||||
ztool=${1}
|
||||
_ztools[${zname}]=${1}
|
||||
;;
|
||||
--no-submodules) zsubmodules=0 ;;
|
||||
-z|--frozen) zfrozen=1 ;;
|
||||
--no-submodules) _zsubmodules[${zname}]=0 ;;
|
||||
-z|--frozen) _zfrozens[${zname}]=1 ;;
|
||||
--on-pull)
|
||||
shift
|
||||
zonpulls+=(${1})
|
||||
_zonpulls[${zname}]="${_zonpulls[${zname}]+${_zonpulls[${zname}]}; }${1}"
|
||||
;;
|
||||
-f|--fpath)
|
||||
shift
|
||||
zarg=${1}
|
||||
if [[ ${zarg} != /* ]] zarg=${zdir}/${zarg}
|
||||
if [[ ${zarg} != /* ]] zarg=${_zdirs[${zname}]}/${zarg}
|
||||
zfpaths+=(${zarg})
|
||||
;;
|
||||
-a|--autoload)
|
||||
|
@ -131,16 +137,16 @@ Initialization options:
|
|||
-s|--source)
|
||||
shift
|
||||
zarg=${1}
|
||||
if [[ ${zarg} != /* ]] zarg=${zdir}/${zarg}
|
||||
if [[ ${zarg} != /* ]] zarg=${_zdirs[${zname}]}/${zarg}
|
||||
zcmds+=("source ${zarg:A}")
|
||||
;;
|
||||
-c|--cmd)
|
||||
shift
|
||||
zcmds+=(${1//{}/${zdir:A}})
|
||||
zcmds+=(${1//{}/${_zdirs[${zname}]:A}})
|
||||
;;
|
||||
-d|--disabled) zdisabled=1 ;;
|
||||
-d|--disabled) _zdisableds[${zname}]=1 ;;
|
||||
*)
|
||||
print -u2 -PlR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option %B${1}%b%f" '' ${zusage}
|
||||
print -u2 -PlR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zname}:%b Unknown zmodule option %B${1}%b%f" '' ${zusage}
|
||||
_zfailed=1
|
||||
return 2
|
||||
;;
|
||||
|
@ -148,42 +154,37 @@ Initialization options:
|
|||
shift
|
||||
done
|
||||
if (( _zflags & 1 )); then
|
||||
_zmodules_zargs+=("${ztool}" "${_zargs_action}" "${zmodule}" "${zdir}" "${zurl}" "${ztype}" "${zrev}" "${zsubmodules}" "${(j:; :)zonpulls}" "${zfrozen}" "${zdisabled}")
|
||||
_znames+=(${zname})
|
||||
fi
|
||||
if (( _zflags & 2 )); then
|
||||
if (( zdisabled )); then
|
||||
_zdisabled_dirs+=(${zdir})
|
||||
if (( _zdisableds[${zname}] )); then
|
||||
_zdisabled_dirs+=(${_zdirs[${zname}]})
|
||||
else
|
||||
if [[ ! -e ${zdir} ]]; then
|
||||
if [[ -z ${zurl} ]]; then
|
||||
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}: ${zdir}%b not found%f"
|
||||
else
|
||||
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Not installed. Run %Bzimfw install%b to install.%f"
|
||||
fi
|
||||
if [[ ! -e ${_zdirs[${zname}]} ]]; then
|
||||
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zname}: ${_zdirs[${zname}]}%b not found%f"
|
||||
_zfailed=1
|
||||
return 1
|
||||
fi
|
||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
||||
zfpaths=(${zdir}/functions(NF))
|
||||
zfpaths=(${_zdirs[${zname}]}/functions(NF))
|
||||
# _* functions are autoloaded by compinit
|
||||
# prompt_*_setup functions are autoloaded by promptinit
|
||||
zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
||||
local -ra prezto_scripts=(${zdir}/init.zsh(N))
|
||||
local -ra prezto_scripts=(${_zdirs[${zname}]}/init.zsh(N))
|
||||
if (( ${#zfpaths} && ${#prezto_scripts} )); then
|
||||
# this follows the prezto module format, no need to check for other scripts
|
||||
zcmds=('source '${^prezto_scripts:A})
|
||||
else
|
||||
# get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first)
|
||||
local -ra zscripts=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||
local -ra zscripts=(${_zdirs[${zname}]}/(init.zsh|${zname:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||
zcmds=('source '${^zscripts:A})
|
||||
fi
|
||||
fi
|
||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
||||
_zimfw_print -u2 -PlR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f" '' ${zusage}
|
||||
_zimfw_print -u2 -PlR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zname}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f" '' ${zusage}
|
||||
fi
|
||||
_zdirs+=(${zdir})
|
||||
# Prefix is added to all _zfpaths, _zfunctions and _zcmds to distinguish the originating modules
|
||||
local -r zpre=${zmodule}$'\0'
|
||||
# Prefix is added to all _zfpaths, _zfunctions and _zcmds to distinguish the originating names
|
||||
local -r zpre=${zname}$'\0'
|
||||
_zfpaths+=(${zpre}${^zfpaths})
|
||||
_zfunctions+=(${zpre}${^zfunctions})
|
||||
_zcmds+=(${zpre}${^zcmds})
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
_zimfw_source_zimrc() {
|
||||
local -r ztarget=<%= home %>/.zimrc _zflags=${1} _zargs_action=${2}
|
||||
local -r ztarget=<%= home %>/.zimrc _zflags=${1}
|
||||
local -i _zfailed=0
|
||||
if ! source ${ztarget} || (( _zfailed )); then
|
||||
print -u2 -PR "%F{red}<%= failed %>Failed to source %B${ztarget}%b%f"
|
||||
return 1
|
||||
fi
|
||||
if (( _zflags & 1 && ${#_zmodules_zargs} == 0 )); then
|
||||
if (( _zflags & 1 && ${#_znames} == 0 )); then
|
||||
print -u2 -PR "%F{red}<%= failed %>No modules defined in %B${ztarget}%b%f"
|
||||
return 1
|
||||
fi
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
_zimfw_list_unuseds() {
|
||||
local -i i=1
|
||||
local -a zinstalled=(${ZIM_HOME}/modules/*(N/))
|
||||
local -ar zdirs=(${(v)_zdirs})
|
||||
# Search into subdirectories
|
||||
while (( i <= ${#zinstalled} )); do
|
||||
if (( ${_zdirs[(I)${zinstalled[i]}/*]} || ${_zdisabled_dirs[(I)${zinstalled[i]}/*]} )); then
|
||||
if (( ${zdirs[(I)${zinstalled[i]}/*]} || ${_zdisabled_dirs[(I)${zinstalled[i]}/*]} )); then
|
||||
zinstalled+=(${zinstalled[i]}/*(N/))
|
||||
zinstalled[i]=()
|
||||
else
|
||||
(( i++ ))
|
||||
fi
|
||||
done
|
||||
# Unused = all installed dirs not in _zdirs and _zdisabled_dirs
|
||||
_zunused_dirs=(${${zinstalled:|_zdirs}:|_zdisabled_dirs})
|
||||
# Unused = all installed dirs not in zdirs and _zdisabled_dirs
|
||||
_zunused_dirs=(${${zinstalled:|zdirs}:|_zdisabled_dirs})
|
||||
local zunused
|
||||
for zunused in ${_zunused_dirs}; do
|
||||
_zimfw_print -PR "%B${zunused:t}:%b ${zunused}${1}"
|
||||
done
|
||||
for zunused (${_zunused_dirs}) _zimfw_print -PR "%B${zunused:t}:%b ${zunused}${1}"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
_zimfw_clean_compiled() {
|
||||
# Array with unique dirs. ${ZIM_HOME} or any subdirectory should only occur once.
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${_zdirs##${ZIM_HOME}/*}:A})
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${(v)_zdirs##${ZIM_HOME}/*}:A})
|
||||
local zopt
|
||||
if (( _zprintlevel > 0 )) zopt=-v
|
||||
command rm -f ${zopt} ${^zscriptdirs}/**/*.zwc(|.old)(N) && \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
_zimfw_compile() {
|
||||
# Array with unique dirs. ${ZIM_HOME} or any subdirectory should only occur once.
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${_zdirs##${ZIM_HOME}/*}:A})
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${(v)_zdirs##${ZIM_HOME}/*}:A})
|
||||
# Compile Zim scripts
|
||||
local zfile
|
||||
for zfile in ${^zscriptdirs}/(^*test*/)#*.zsh(|-theme)(N-.); do
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
_zimfw_install_update() {
|
||||
_zimfw_source_zimrc 1 ${1} && zargs -n 11 -P 0 -- "${_zmodules_zargs[@]}" -- _zimfw_run_tool
|
||||
local -r _zargs_action=${1}
|
||||
_zimfw_source_zimrc 1 && zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
|
||||
# Ignore return from zargs with -P
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
_zimfw_run_list() {
|
||||
local -r ztool=${1} zmodule=${3} zdir=${4} zurl=${5} ztype=${6} zrev=${7} zonpull=${9}
|
||||
local -ri zsubmodules=${8} zfrozen=${10} zdisabled=${11}
|
||||
print -PnR "%B${zmodule}:%b ${zdir}"
|
||||
if [[ -z ${zurl} ]] print -Pn ' (external)'
|
||||
if (( ${zfrozen} )) print -Pn ' (frozen)'
|
||||
if (( ${zdisabled} )) print -Pn ' (disabled)'
|
||||
local -r zname=${1}
|
||||
print -PnR "%B${zname}:%b ${_zdirs[${zname}]}"
|
||||
if [[ -z ${_zurls[${zname}]} ]] print -Pn ' (external)'
|
||||
if (( ${_zfrozens[${zname}]} )) print -Pn ' (frozen)'
|
||||
if (( ${_zdisableds[${zname}]} )) print -Pn ' (disabled)'
|
||||
print
|
||||
if (( _zprintlevel > 1 )); then
|
||||
if [[ ${zfrozen} -eq 0 && -n ${zurl} ]]; then
|
||||
print -nR " From: ${zurl}, "
|
||||
if [[ -z ${zrev} ]]; then
|
||||
if [[ ${_zfrozens[${zname}]} -eq 0 && -n ${_zurls[${zname}]} ]]; then
|
||||
print -nR " From: ${_zurls[${zname}]}, "
|
||||
if [[ -z ${_zrevs[${zname}]} ]]; then
|
||||
print -n 'default branch'
|
||||
else
|
||||
print -nR "${ztype} ${zrev}"
|
||||
print -nR "${_ztypes[${zname}]} ${_zrevs[${zname}]}"
|
||||
fi
|
||||
print -nR ", using ${ztool}"
|
||||
if (( ! zsubmodules )) print -nR ', no git submodules'
|
||||
print -nR ", using ${_ztools[${zname}]}"
|
||||
if (( ! _zsubmodules[${zname}] )) print -nR ', no git submodules'
|
||||
print
|
||||
if [[ -n ${zonpull} ]] print -R " On-pull: ${zonpull}"
|
||||
if [[ -n ${_zonpulls[${zname}]} ]] print -R " On-pull: ${_zonpulls[${zname}]}"
|
||||
fi
|
||||
# Match and remove the current module prefix from _zfpaths, _zfunctions and _zcmds
|
||||
local -r zpre=${zmodule}$'\0'
|
||||
local -r zpre=${zname}$'\0'
|
||||
local -r zfpaths=(${${(M)_zfpaths:#${zpre}*}#${zpre}}) zfunctions=(${${(M)_zfunctions:#${zpre}*}#${zpre}}) zcmds=(${${(M)_zcmds:#${zpre}*}#${zpre}})
|
||||
if (( ${#zfpaths} )) print -R ' fpath: '${zfpaths}
|
||||
if (( ${#zfunctions} )) print -R ' autoload: '${zfunctions}
|
||||
|
|
|
@ -1,41 +1,40 @@
|
|||
_zimfw_run_tool() {
|
||||
local -r ztool=${1} zaction=${2} zmodule=${3} zdir=${4} zurl=${5}
|
||||
if [[ -z ${zurl} ]]; then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR <%= clear_line %>"<%= okay %>%B${zmodule}:%b Skipping external module"
|
||||
local -r zname=${1}
|
||||
if [[ -z ${_zurls[${zname}]} ]]; then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR <%= clear_line %>"<%= okay %>%B${zname}:%b Skipping external module"
|
||||
return 0
|
||||
fi
|
||||
local -ri zfrozen=${10}
|
||||
if (( zfrozen )); then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR <%= clear_line %>"<%= okay %>%B${zmodule}:%b Skipping frozen module"
|
||||
if (( _zfrozens[${zname}] )); then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR <%= clear_line %>"<%= okay %>%B${zname}:%b Skipping frozen module"
|
||||
return 0
|
||||
fi
|
||||
case ${zaction} in
|
||||
case ${_zargs_action} in
|
||||
install)
|
||||
if [[ -e ${zdir} ]]; then
|
||||
# Already installed
|
||||
if [[ -e ${_zdirs[${zname}]} ]]; then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR <%= clear_line %>"<%= okay %>%B${zname}:%b Skipping already installed module"
|
||||
return 0
|
||||
fi
|
||||
_zimfw_print -nR <%= clear_line %>"Installing ${zmodule}<%= ellipsis %>"
|
||||
_zimfw_print -nR <%= clear_line %>"Installing ${zname}<%= ellipsis %>"
|
||||
;;
|
||||
update)
|
||||
if [[ ! -d ${zdir} ]]; then
|
||||
print -u2 -PR <%= clear_line %>"%F{red}<%= error %>%B${zmodule}:%b Not installed. Run %Bzimfw install%b to install.%f"
|
||||
if [[ ! -d ${_zdirs[${zname}]} ]]; then
|
||||
print -u2 -PR <%= clear_line %>"%F{red}<%= error %>%B${zname}:%b Not installed. Run %Bzimfw install%b to install.%f"
|
||||
return 1
|
||||
fi
|
||||
_zimfw_print -nR <%= clear_line %>"Updating ${zmodule}<%= ellipsis %>"
|
||||
_zimfw_print -nR <%= clear_line %>"Updating ${zname}<%= ellipsis %>"
|
||||
;;
|
||||
*)
|
||||
print -u2 -PR <%= clear_line %>"%F{red}<%= error %>%B${zmodule}:%b Unknown action ${zaction}%f"
|
||||
print -u2 -PR <%= clear_line %>"%F{red}<%= error %>%B${zname}:%b Unknown action ${_zargs_action}%f"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
local zcmd
|
||||
case ${ztool} in
|
||||
case ${_ztools[${zname}]} in
|
||||
<%= render_tools("src/tools/*", "zcmd") %>
|
||||
*)
|
||||
print -u2 -PR "<%= clear_line %>%F{red}<%= error %>%B${zmodule}:%b Unknown tool ${ztool}%f"
|
||||
print -u2 -PR "<%= clear_line %>%F{red}<%= error %>%B${zname}:%b Unknown tool ${_ztools[${zname}]}%f"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
zsh -c ${zcmd} ${ztool} ${_zprintlevel} "${@[2,9]}"
|
||||
zsh -c ${zcmd} ${_ztools[${zname}]} "${_zprintlevel}" "${_zargs_action}" "${zname}" "${_zdirs[${zname}]}" "${_zurls[${zname}]}" "${_ztypes[${zname}]}" "${_zrevs[${zname}]}" "${_zsubmodules[${zname}]}" "${_zonpulls[${zname}]}"
|
||||
}
|
||||
|
|
|
@ -26,7 +26,9 @@ Actions:
|
|||
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 -Ua _znames _zdisabled_dirs
|
||||
local -A _zfrozens _zdisableds _ztools _zdirs _zurls _ztypes _zrevs _zsubmodules _zonpulls
|
||||
local -a _zfpaths _zfunctions _zcmds _zunused_dirs
|
||||
local -i _zprintlevel=1
|
||||
if (( # > 2 )); then
|
||||
print -u2 -PlR "%F{red}${0}: Too many options%f" '' ${zusage}
|
||||
|
@ -57,11 +59,11 @@ Options:
|
|||
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_compile ;;
|
||||
compile) _zimfw_source_zimrc 2 && _zimfw_compile ;;
|
||||
help) print -PR ${zusage} ;;
|
||||
info) _zimfw_info ;;
|
||||
list)
|
||||
_zimfw_source_zimrc 3 && zargs -n 11 -- "${_zmodules_zargs[@]}" -- _zimfw_run_list && \
|
||||
_zimfw_source_zimrc 3 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \
|
||||
_zimfw_list_unuseds ' (unused)'
|
||||
;;
|
||||
init)
|
||||
|
@ -81,7 +83,7 @@ Options:
|
|||
upgrade)
|
||||
_zimfw_upgrade || return 1
|
||||
(( _zprintlevel-- ))
|
||||
_zimfw_compile
|
||||
_zimfw_source_zimrc 2 && _zimfw_compile
|
||||
;;
|
||||
version) print -PR ${_zversion} ;;
|
||||
*)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This runs in a new shell
|
||||
builtin emulate -L zsh
|
||||
readonly -i PRINTLEVEL=${1} SUBMODULES=${8}
|
||||
readonly ACTION=${2} MODULE=${3} DIR=${4} URL=${5} TYPE=${6:=branch} ONPULL=${9}
|
||||
readonly ACTION=${2} MODULE=${3} DIR=${4} URL=${5} TYPE=${6} ONPULL=${9}
|
||||
REV=${7}
|
||||
|
||||
print_error() {
|
||||
|
|
|
@ -4,7 +4,7 @@ class Zim
|
|||
:clear_line, :ellipsis, :okay, :warn, :error, :done, :failed
|
||||
|
||||
def initialize
|
||||
@version = "1.9.0"
|
||||
@version = "1.9.1-SNAPSHOT"
|
||||
@home = "${ZDOTDIR:-${HOME}}"
|
||||
@min_zsh_version = "5.2"
|
||||
# Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo
|
||||
|
|
185
zimfw.zsh
185
zimfw.zsh
|
@ -138,12 +138,10 @@ Initialization options:
|
|||
_zfailed=1
|
||||
return 2
|
||||
fi
|
||||
local zurl=${1} zmodule=${1:t} ztool zdir ztype zrev zarg
|
||||
local -i zsubmodules=1 zfrozen=0 zdisabled=0
|
||||
local -a zonpulls zfpaths zfunctions zcmds
|
||||
zstyle -s ':zim:zmodule' use 'ztool' || ztool=git
|
||||
local zurl=${1} zname=${1:t} zarg
|
||||
local -a zfpaths zfunctions zcmds
|
||||
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
||||
zmodule=${zmodule%.git}
|
||||
zname=${zname%.git}
|
||||
elif [[ ${zurl} != /* ]]; then
|
||||
# Count number of slashes
|
||||
case ${#zurl//[^\/]/} in
|
||||
|
@ -152,27 +150,35 @@ Initialization options:
|
|||
esac
|
||||
fi
|
||||
shift
|
||||
if [[ ${1} == (-n|--name) ]]; then
|
||||
while [[ ${1} == (-n|--name) ]]; do
|
||||
if (( # < 2 )); then
|
||||
print -u2 -PlR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option %B${1}%b%f" '' ${zusage}
|
||||
print -u2 -PlR "%F{red}x ${funcfiletrace[1]}:%B${zname}:%b Missing argument for zmodule option %B${1}%b%f" '' ${zusage}
|
||||
_zfailed=1
|
||||
return 2
|
||||
fi
|
||||
shift
|
||||
zmodule=${${1%%/##}##/##}
|
||||
zname=${${1%%/##}##/##}
|
||||
shift
|
||||
fi
|
||||
done
|
||||
if [[ ${zurl} == /* ]]; then
|
||||
zdir=${zurl%%/##}
|
||||
_zdirs[${zname}]=${zurl%%/##}
|
||||
zurl=
|
||||
else
|
||||
zdir=${ZIM_HOME}/modules/${zmodule}
|
||||
_zdirs[${zname}]=${ZIM_HOME}/modules/${zname}
|
||||
fi
|
||||
_zurls[${zname}]=${zurl}
|
||||
# Set default values
|
||||
if (( ! ${+_ztools[${zname}]} )); then
|
||||
zstyle -s ':zim:zmodule' use "_ztools[${zname}]" || _ztools[${zname}]=git
|
||||
fi
|
||||
if (( ! ${+_ztypes[${zname}]} )) _ztypes[${zname}]=branch
|
||||
if (( ! ${+_zsubmodules[${zname}]} )) _zsubmodules[${zname}]=1
|
||||
# Set values from options
|
||||
while (( # > 0 )); do
|
||||
case ${1} in
|
||||
-b|--branch|-t|--tag|-u|--use|--on-pull|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
|
||||
if (( # < 2 )); then
|
||||
print -u2 -PlR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option %B${1}%b%f" '' ${zusage}
|
||||
print -u2 -PlR "%F{red}x ${funcfiletrace[1]}:%B${zname}:%b Missing argument for zmodule option %B${1}%b%f" '' ${zusage}
|
||||
_zfailed=1
|
||||
return 2
|
||||
fi
|
||||
|
@ -180,34 +186,34 @@ Initialization options:
|
|||
esac
|
||||
case ${1} in
|
||||
-b|--branch|-t|--tag|-u|--use|--no-submodules)
|
||||
if [[ -z ${zurl} ]] _zimfw_print -u2 -PR "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b The zmodule option %B${1}%b has no effect for external modules%f"
|
||||
if [[ -z ${zurl} ]] _zimfw_print -u2 -PR "%F{yellow}! ${funcfiletrace[1]}:%B${zname}:%b The zmodule option %B${1}%b has no effect for external modules%f"
|
||||
;;
|
||||
esac
|
||||
case ${1} in
|
||||
-b|--branch)
|
||||
shift
|
||||
ztype=branch
|
||||
zrev=${1}
|
||||
_ztypes[${zname}]=branch
|
||||
_zrevs[${zname}]=${1}
|
||||
;;
|
||||
-t|--tag)
|
||||
shift
|
||||
ztype=tag
|
||||
zrev=${1}
|
||||
_ztypes[${zname}]=tag
|
||||
_zrevs[${zname}]=${1}
|
||||
;;
|
||||
-u|--use)
|
||||
shift
|
||||
ztool=${1}
|
||||
_ztools[${zname}]=${1}
|
||||
;;
|
||||
--no-submodules) zsubmodules=0 ;;
|
||||
-z|--frozen) zfrozen=1 ;;
|
||||
--no-submodules) _zsubmodules[${zname}]=0 ;;
|
||||
-z|--frozen) _zfrozens[${zname}]=1 ;;
|
||||
--on-pull)
|
||||
shift
|
||||
zonpulls+=(${1})
|
||||
_zonpulls[${zname}]="${_zonpulls[${zname}]+${_zonpulls[${zname}]}; }${1}"
|
||||
;;
|
||||
-f|--fpath)
|
||||
shift
|
||||
zarg=${1}
|
||||
if [[ ${zarg} != /* ]] zarg=${zdir}/${zarg}
|
||||
if [[ ${zarg} != /* ]] zarg=${_zdirs[${zname}]}/${zarg}
|
||||
zfpaths+=(${zarg})
|
||||
;;
|
||||
-a|--autoload)
|
||||
|
@ -217,16 +223,16 @@ Initialization options:
|
|||
-s|--source)
|
||||
shift
|
||||
zarg=${1}
|
||||
if [[ ${zarg} != /* ]] zarg=${zdir}/${zarg}
|
||||
if [[ ${zarg} != /* ]] zarg=${_zdirs[${zname}]}/${zarg}
|
||||
zcmds+=("source ${zarg:A}")
|
||||
;;
|
||||
-c|--cmd)
|
||||
shift
|
||||
zcmds+=(${1//{}/${zdir:A}})
|
||||
zcmds+=(${1//{}/${_zdirs[${zname}]:A}})
|
||||
;;
|
||||
-d|--disabled) zdisabled=1 ;;
|
||||
-d|--disabled) _zdisableds[${zname}]=1 ;;
|
||||
*)
|
||||
print -u2 -PlR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option %B${1}%b%f" '' ${zusage}
|
||||
print -u2 -PlR "%F{red}x ${funcfiletrace[1]}:%B${zname}:%b Unknown zmodule option %B${1}%b%f" '' ${zusage}
|
||||
_zfailed=1
|
||||
return 2
|
||||
;;
|
||||
|
@ -234,42 +240,37 @@ Initialization options:
|
|||
shift
|
||||
done
|
||||
if (( _zflags & 1 )); then
|
||||
_zmodules_zargs+=("${ztool}" "${_zargs_action}" "${zmodule}" "${zdir}" "${zurl}" "${ztype}" "${zrev}" "${zsubmodules}" "${(j:; :)zonpulls}" "${zfrozen}" "${zdisabled}")
|
||||
_znames+=(${zname})
|
||||
fi
|
||||
if (( _zflags & 2 )); then
|
||||
if (( zdisabled )); then
|
||||
_zdisabled_dirs+=(${zdir})
|
||||
if (( _zdisableds[${zname}] )); then
|
||||
_zdisabled_dirs+=(${_zdirs[${zname}]})
|
||||
else
|
||||
if [[ ! -e ${zdir} ]]; then
|
||||
if [[ -z ${zurl} ]]; then
|
||||
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}: ${zdir}%b not found%f"
|
||||
else
|
||||
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Not installed. Run %Bzimfw install%b to install.%f"
|
||||
fi
|
||||
if [[ ! -e ${_zdirs[${zname}]} ]]; then
|
||||
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zname}: ${_zdirs[${zname}]}%b not found%f"
|
||||
_zfailed=1
|
||||
return 1
|
||||
fi
|
||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
||||
zfpaths=(${zdir}/functions(NF))
|
||||
zfpaths=(${_zdirs[${zname}]}/functions(NF))
|
||||
# _* functions are autoloaded by compinit
|
||||
# prompt_*_setup functions are autoloaded by promptinit
|
||||
zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
||||
local -ra prezto_scripts=(${zdir}/init.zsh(N))
|
||||
local -ra prezto_scripts=(${_zdirs[${zname}]}/init.zsh(N))
|
||||
if (( ${#zfpaths} && ${#prezto_scripts} )); then
|
||||
# this follows the prezto module format, no need to check for other scripts
|
||||
zcmds=('source '${^prezto_scripts:A})
|
||||
else
|
||||
# get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first)
|
||||
local -ra zscripts=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||
local -ra zscripts=(${_zdirs[${zname}]}/(init.zsh|${zname:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||
zcmds=('source '${^zscripts:A})
|
||||
fi
|
||||
fi
|
||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
||||
_zimfw_print -u2 -PlR "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f" '' ${zusage}
|
||||
_zimfw_print -u2 -PlR "%F{yellow}! ${funcfiletrace[1]}:%B${zname}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f" '' ${zusage}
|
||||
fi
|
||||
_zdirs+=(${zdir})
|
||||
# Prefix is added to all _zfpaths, _zfunctions and _zcmds to distinguish the originating modules
|
||||
local -r zpre=${zmodule}$'\0'
|
||||
# Prefix is added to all _zfpaths, _zfunctions and _zcmds to distinguish the originating names
|
||||
local -r zpre=${zname}$'\0'
|
||||
_zfpaths+=(${zpre}${^zfpaths})
|
||||
_zfunctions+=(${zpre}${^zfunctions})
|
||||
_zcmds+=(${zpre}${^zcmds})
|
||||
|
@ -278,13 +279,13 @@ Initialization options:
|
|||
}
|
||||
|
||||
_zimfw_source_zimrc() {
|
||||
local -r ztarget=${ZDOTDIR:-${HOME}}/.zimrc _zflags=${1} _zargs_action=${2}
|
||||
local -r ztarget=${ZDOTDIR:-${HOME}}/.zimrc _zflags=${1}
|
||||
local -i _zfailed=0
|
||||
if ! source ${ztarget} || (( _zfailed )); then
|
||||
print -u2 -PR "%F{red}Failed to source %B${ztarget}%b%f"
|
||||
return 1
|
||||
fi
|
||||
if (( _zflags & 1 && ${#_zmodules_zargs} == 0 )); then
|
||||
if (( _zflags & 1 && ${#_znames} == 0 )); then
|
||||
print -u2 -PR "%F{red}No modules defined in %B${ztarget}%b%f"
|
||||
return 1
|
||||
fi
|
||||
|
@ -293,21 +294,20 @@ _zimfw_source_zimrc() {
|
|||
_zimfw_list_unuseds() {
|
||||
local -i i=1
|
||||
local -a zinstalled=(${ZIM_HOME}/modules/*(N/))
|
||||
local -ar zdirs=(${(v)_zdirs})
|
||||
# Search into subdirectories
|
||||
while (( i <= ${#zinstalled} )); do
|
||||
if (( ${_zdirs[(I)${zinstalled[i]}/*]} || ${_zdisabled_dirs[(I)${zinstalled[i]}/*]} )); then
|
||||
if (( ${zdirs[(I)${zinstalled[i]}/*]} || ${_zdisabled_dirs[(I)${zinstalled[i]}/*]} )); then
|
||||
zinstalled+=(${zinstalled[i]}/*(N/))
|
||||
zinstalled[i]=()
|
||||
else
|
||||
(( i++ ))
|
||||
fi
|
||||
done
|
||||
# Unused = all installed dirs not in _zdirs and _zdisabled_dirs
|
||||
_zunused_dirs=(${${zinstalled:|_zdirs}:|_zdisabled_dirs})
|
||||
# Unused = all installed dirs not in zdirs and _zdisabled_dirs
|
||||
_zunused_dirs=(${${zinstalled:|zdirs}:|_zdisabled_dirs})
|
||||
local zunused
|
||||
for zunused in ${_zunused_dirs}; do
|
||||
_zimfw_print -PR "%B${zunused:t}:%b ${zunused}${1}"
|
||||
done
|
||||
for zunused (${_zunused_dirs}) _zimfw_print -PR "%B${zunused:t}:%b ${zunused}${1}"
|
||||
}
|
||||
|
||||
_zimfw_version_check() {
|
||||
|
@ -355,7 +355,7 @@ _zimfw_check_dumpfile() {
|
|||
|
||||
_zimfw_clean_compiled() {
|
||||
# Array with unique dirs. ${ZIM_HOME} or any subdirectory should only occur once.
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${_zdirs##${ZIM_HOME}/*}:A})
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${(v)_zdirs##${ZIM_HOME}/*}:A})
|
||||
local zopt
|
||||
if (( _zprintlevel > 0 )) zopt=-v
|
||||
command rm -f ${zopt} ${^zscriptdirs}/**/*.zwc(|.old)(N) && \
|
||||
|
@ -372,7 +372,7 @@ _zimfw_clean_dumpfile() {
|
|||
|
||||
_zimfw_compile() {
|
||||
# Array with unique dirs. ${ZIM_HOME} or any subdirectory should only occur once.
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${_zdirs##${ZIM_HOME}/*}:A})
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${(v)_zdirs##${ZIM_HOME}/*}:A})
|
||||
# Compile Zim scripts
|
||||
local zfile
|
||||
for zfile in ${^zscriptdirs}/(^*test*/)#*.zsh(|-theme)(N-.); do
|
||||
|
@ -384,14 +384,17 @@ _zimfw_compile() {
|
|||
}
|
||||
|
||||
_zimfw_info() {
|
||||
print -R 'zimfw version: '${_zversion}' (built at 2022-05-09 23:35:03 UTC, previous commit is 741bb78)'
|
||||
print -R 'zimfw version: '${_zversion}' (built at 2022-05-17 23:38:19 UTC, previous commit is d6b4aa6)'
|
||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||
print -R 'Zsh version: '${ZSH_VERSION}
|
||||
print -R 'System info: '$(command uname -a)
|
||||
}
|
||||
|
||||
_zimfw_install_update() {
|
||||
_zimfw_source_zimrc 1 ${1} && zargs -n 11 -P 0 -- "${_zmodules_zargs[@]}" -- _zimfw_run_tool
|
||||
local -r _zargs_action=${1}
|
||||
_zimfw_source_zimrc 1 && zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
|
||||
# Ignore return from zargs with -P
|
||||
return 0
|
||||
}
|
||||
|
||||
_zimfw_uninstall() {
|
||||
|
@ -432,28 +435,27 @@ _zimfw_upgrade() {
|
|||
}
|
||||
|
||||
_zimfw_run_list() {
|
||||
local -r ztool=${1} zmodule=${3} zdir=${4} zurl=${5} ztype=${6} zrev=${7} zonpull=${9}
|
||||
local -ri zsubmodules=${8} zfrozen=${10} zdisabled=${11}
|
||||
print -PnR "%B${zmodule}:%b ${zdir}"
|
||||
if [[ -z ${zurl} ]] print -Pn ' (external)'
|
||||
if (( ${zfrozen} )) print -Pn ' (frozen)'
|
||||
if (( ${zdisabled} )) print -Pn ' (disabled)'
|
||||
local -r zname=${1}
|
||||
print -PnR "%B${zname}:%b ${_zdirs[${zname}]}"
|
||||
if [[ -z ${_zurls[${zname}]} ]] print -Pn ' (external)'
|
||||
if (( ${_zfrozens[${zname}]} )) print -Pn ' (frozen)'
|
||||
if (( ${_zdisableds[${zname}]} )) print -Pn ' (disabled)'
|
||||
print
|
||||
if (( _zprintlevel > 1 )); then
|
||||
if [[ ${zfrozen} -eq 0 && -n ${zurl} ]]; then
|
||||
print -nR " From: ${zurl}, "
|
||||
if [[ -z ${zrev} ]]; then
|
||||
if [[ ${_zfrozens[${zname}]} -eq 0 && -n ${_zurls[${zname}]} ]]; then
|
||||
print -nR " From: ${_zurls[${zname}]}, "
|
||||
if [[ -z ${_zrevs[${zname}]} ]]; then
|
||||
print -n 'default branch'
|
||||
else
|
||||
print -nR "${ztype} ${zrev}"
|
||||
print -nR "${_ztypes[${zname}]} ${_zrevs[${zname}]}"
|
||||
fi
|
||||
print -nR ", using ${ztool}"
|
||||
if (( ! zsubmodules )) print -nR ', no git submodules'
|
||||
print -nR ", using ${_ztools[${zname}]}"
|
||||
if (( ! _zsubmodules[${zname}] )) print -nR ', no git submodules'
|
||||
print
|
||||
if [[ -n ${zonpull} ]] print -R " On-pull: ${zonpull}"
|
||||
if [[ -n ${_zonpulls[${zname}]} ]] print -R " On-pull: ${_zonpulls[${zname}]}"
|
||||
fi
|
||||
# Match and remove the current module prefix from _zfpaths, _zfunctions and _zcmds
|
||||
local -r zpre=${zmodule}$'\0'
|
||||
local -r zpre=${zname}$'\0'
|
||||
local -r zfpaths=(${${(M)_zfpaths:#${zpre}*}#${zpre}}) zfunctions=(${${(M)_zfunctions:#${zpre}*}#${zpre}}) zcmds=(${${(M)_zcmds:#${zpre}*}#${zpre}})
|
||||
if (( ${#zfpaths} )) print -R ' fpath: '${zfpaths}
|
||||
if (( ${#zfunctions} )) print -R ' autoload: '${zfunctions}
|
||||
|
@ -462,38 +464,37 @@ _zimfw_run_list() {
|
|||
}
|
||||
|
||||
_zimfw_run_tool() {
|
||||
local -r ztool=${1} zaction=${2} zmodule=${3} zdir=${4} zurl=${5}
|
||||
if [[ -z ${zurl} ]]; then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR $'\E[2K\r'"%F{green})%f %B${zmodule}:%b Skipping external module"
|
||||
local -r zname=${1}
|
||||
if [[ -z ${_zurls[${zname}]} ]]; then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR $'\E[2K\r'"%F{green})%f %B${zname}:%b Skipping external module"
|
||||
return 0
|
||||
fi
|
||||
local -ri zfrozen=${10}
|
||||
if (( zfrozen )); then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR $'\E[2K\r'"%F{green})%f %B${zmodule}:%b Skipping frozen module"
|
||||
if (( _zfrozens[${zname}] )); then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR $'\E[2K\r'"%F{green})%f %B${zname}:%b Skipping frozen module"
|
||||
return 0
|
||||
fi
|
||||
case ${zaction} in
|
||||
case ${_zargs_action} in
|
||||
install)
|
||||
if [[ -e ${zdir} ]]; then
|
||||
# Already installed
|
||||
if [[ -e ${_zdirs[${zname}]} ]]; then
|
||||
if (( _zprintlevel > 1 )) print -u2 -PR $'\E[2K\r'"%F{green})%f %B${zname}:%b Skipping already installed module"
|
||||
return 0
|
||||
fi
|
||||
_zimfw_print -nR $'\E[2K\r'"Installing ${zmodule} ..."
|
||||
_zimfw_print -nR $'\E[2K\r'"Installing ${zname} ..."
|
||||
;;
|
||||
update)
|
||||
if [[ ! -d ${zdir} ]]; then
|
||||
print -u2 -PR $'\E[2K\r'"%F{red}x %B${zmodule}:%b Not installed. Run %Bzimfw install%b to install.%f"
|
||||
if [[ ! -d ${_zdirs[${zname}]} ]]; then
|
||||
print -u2 -PR $'\E[2K\r'"%F{red}x %B${zname}:%b Not installed. Run %Bzimfw install%b to install.%f"
|
||||
return 1
|
||||
fi
|
||||
_zimfw_print -nR $'\E[2K\r'"Updating ${zmodule} ..."
|
||||
_zimfw_print -nR $'\E[2K\r'"Updating ${zname} ..."
|
||||
;;
|
||||
*)
|
||||
print -u2 -PR $'\E[2K\r'"%F{red}x %B${zmodule}:%b Unknown action ${zaction}%f"
|
||||
print -u2 -PR $'\E[2K\r'"%F{red}x %B${zname}:%b Unknown action ${_zargs_action}%f"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
local zcmd
|
||||
case ${ztool} in
|
||||
case ${_ztools[${zname}]} in
|
||||
degit) zcmd="# This runs in a new shell
|
||||
builtin emulate -L zsh -o EXTENDED_GLOB
|
||||
readonly -i PRINTLEVEL=\${1} SUBMODULES=\${8}
|
||||
|
@ -649,7 +650,7 @@ esac
|
|||
git) zcmd="# This runs in a new shell
|
||||
builtin emulate -L zsh
|
||||
readonly -i PRINTLEVEL=\${1} SUBMODULES=\${8}
|
||||
readonly ACTION=\${2} MODULE=\${3} DIR=\${4} URL=\${5} TYPE=\${6:=branch} ONPULL=\${9}
|
||||
readonly ACTION=\${2} MODULE=\${3} DIR=\${4} URL=\${5} TYPE=\${6} ONPULL=\${9}
|
||||
REV=\${7}
|
||||
|
||||
print_error() {
|
||||
|
@ -745,16 +746,16 @@ case \${ACTION} in
|
|||
esac
|
||||
" ;;
|
||||
*)
|
||||
print -u2 -PR "$'\E[2K\r'%F{red}x %B${zmodule}:%b Unknown tool ${ztool}%f"
|
||||
print -u2 -PR "$'\E[2K\r'%F{red}x %B${zname}:%b Unknown tool ${_ztools[${zname}]}%f"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
zsh -c ${zcmd} ${ztool} ${_zprintlevel} "${@[2,9]}"
|
||||
zsh -c ${zcmd} ${_ztools[${zname}]} "${_zprintlevel}" "${_zargs_action}" "${zname}" "${_zdirs[${zname}]}" "${_zurls[${zname}]}" "${_ztypes[${zname}]}" "${_zrevs[${zname}]}" "${_zsubmodules[${zname}]}" "${_zonpulls[${zname}]}"
|
||||
}
|
||||
|
||||
zimfw() {
|
||||
builtin emulate -L zsh -o EXTENDED_GLOB
|
||||
local -r _zversion='1.9.0' zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
|
||||
local -r _zversion='1.9.1-SNAPSHOT' 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.
|
||||
|
@ -780,7 +781,9 @@ Actions:
|
|||
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 -Ua _znames _zdisabled_dirs
|
||||
local -A _zfrozens _zdisableds _ztools _zdirs _zurls _ztypes _zrevs _zsubmodules _zonpulls
|
||||
local -a _zfpaths _zfunctions _zcmds _zunused_dirs
|
||||
local -i _zprintlevel=1
|
||||
if (( # > 2 )); then
|
||||
print -u2 -PlR "%F{red}${0}: Too many options%f" '' ${zusage}
|
||||
|
@ -811,11 +814,11 @@ Options:
|
|||
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_compile ;;
|
||||
compile) _zimfw_source_zimrc 2 && _zimfw_compile ;;
|
||||
help) print -PR ${zusage} ;;
|
||||
info) _zimfw_info ;;
|
||||
list)
|
||||
_zimfw_source_zimrc 3 && zargs -n 11 -- "${_zmodules_zargs[@]}" -- _zimfw_run_list && \
|
||||
_zimfw_source_zimrc 3 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \
|
||||
_zimfw_list_unuseds ' (unused)'
|
||||
;;
|
||||
init)
|
||||
|
@ -835,7 +838,7 @@ Options:
|
|||
upgrade)
|
||||
_zimfw_upgrade || return 1
|
||||
(( _zprintlevel-- ))
|
||||
_zimfw_compile
|
||||
_zimfw_source_zimrc 2 && _zimfw_compile
|
||||
;;
|
||||
version) print -PR ${_zversion} ;;
|
||||
*)
|
||||
|
|
Loading…
Reference in a new issue