1
0
Fork 0
mirror of synced 2024-12-24 23:13:21 -05:00

Add --if-command option to zmodule

This commit is contained in:
Eric Nielsen 2024-01-22 21:36:17 -05:00
parent 5f649d3031
commit 8bec2f7549
No known key found for this signature in database
GPG key ID: 678AF5E338C87D99
4 changed files with 28 additions and 4 deletions

View file

@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
_No unreleased changes._
### Added
- `--if-command` option to zmodule. This option is equivalent to
`--if "(( \${+commands[${1}]} ))"`.
## [1.12.1] - 2023-09-16

View file

@ -255,6 +255,9 @@ Per-module options:
Per-module-root options:
<b>--if</b> &lt;test&gt; Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup.
<b>--if-command</b> &lt;command&gt; Will only initialize module root if specified external command is
available. This is evaluated at every new terminal startup.
Equivalent to <b>--if "(( \\\${+commands[\${1}]} ))"</b>.
<b>--on-pull</b> &lt;command&gt; Execute command after installing or updating the module. The com-
mand is executed in the module root directory.
<b>-d</b>|<b>--disabled</b> Don&apos;t initialize the module root or uninstall the module.

View file

@ -36,6 +36,9 @@ Per-module options:
Per-module-root options:
<%= bold %>--if<%= normal %> <test> Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup.
<%= bold %>--if-command<%= normal %> <command> Will only initialize module root if specified external command is
available. This is evaluated at every new terminal startup.
Equivalent to <%= bold %>--if "(( \\\${+commands[\${1}]} ))"<%= normal %>.
<%= bold %>--on-pull<%= normal %> <command> Execute command after installing or updating the module. The com-
mand is executed in the module root directory.
<%= bold %>-d<%= normal %>|<%= bold %>--disabled<%= normal %> Don\'t initialize the module root or uninstall the module.
@ -125,7 +128,7 @@ Per-call initialization options:
# Set values from options
while (( # > 0 )); do
case ${1} in
-b|--branch|-t|--tag|-u|--use|--on-pull|--if|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
-b|--branch|-t|--tag|-u|--use|--on-pull|--if|--if-command|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
if (( # < 2 )); then
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Missing argument for zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage}
_zfailed=1
@ -165,6 +168,10 @@ Per-call initialization options:
shift
_zifs[${zroot_dir}]=${1}
;;
--if-command)
shift
_zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
;;
-f|--fpath)
shift
zarg=${1}

View file

@ -106,6 +106,9 @@ _zimfw_build_login_init() {
) ${ztarget}
}
zeval() {
}
_zimfw_build() {
_zimfw_build_init && _zimfw_build_login_init && _zimfw_print 'Done with build.'
}
@ -148,6 +151,9 @@ Per-module options:
Per-module-root options:
\E[1m--if\E[0m <test> Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup.
\E[1m--if-command\E[0m <command> Will only initialize module root if specified external command is
available. This is evaluated at every new terminal startup.
Equivalent to \E[1m--if "(( \\\${+commands[\${1}]} ))"\E[0m.
\E[1m--on-pull\E[0m <command> Execute command after installing or updating the module. The com-
mand is executed in the module root directory.
\E[1m-d\E[0m|\E[1m--disabled\E[0m Don\'t initialize the module root or uninstall the module.
@ -237,7 +243,7 @@ Per-call initialization options:
# Set values from options
while (( # > 0 )); do
case ${1} in
-b|--branch|-t|--tag|-u|--use|--on-pull|--if|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
-b|--branch|-t|--tag|-u|--use|--on-pull|--if|--if-command|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
if (( # < 2 )); then
print -u2 -lR $'\E[31mx '${funcfiletrace[1]}$':\E[1m'${zname}$':\E[0;31m Missing argument for zmodule option \E[1m'${1}$'\E[0m' '' ${zusage}
_zfailed=1
@ -277,6 +283,10 @@ Per-call initialization options:
shift
_zifs[${zroot_dir}]=${1}
;;
--if-command)
shift
_zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
;;
-f|--fpath)
shift
zarg=${1}
@ -444,7 +454,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2023-09-16 18:25:16 UTC, previous commit is 26151d2)'
print -R 'zimfw version: '${_zversion}' (built at 2024-01-23 02:30:19 UTC, previous commit is 5f649d3)'
local zparam
for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do
print -R ${(r.22....:.)zparam}${(P)zparam}