Add --if-command
option to zmodule
This commit is contained in:
parent
5f649d3031
commit
8bec2f7549
4 changed files with 28 additions and 4 deletions
|
@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
_No unreleased changes._
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `--if-command` option to zmodule. This option is equivalent to
|
||||||
|
`--if "(( \${+commands[${1}]} ))"`.
|
||||||
|
|
||||||
## [1.12.1] - 2023-09-16
|
## [1.12.1] - 2023-09-16
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,9 @@ Per-module options:
|
||||||
Per-module-root options:
|
Per-module-root options:
|
||||||
<b>--if</b> <test> Will only initialize module root if specified test returns a zero
|
<b>--if</b> <test> Will only initialize module root if specified test returns a zero
|
||||||
exit status. The test is evaluated at every new terminal startup.
|
exit status. The test is evaluated at every new terminal startup.
|
||||||
|
<b>--if-command</b> <command> 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> <command> Execute command after installing or updating the module. The com-
|
<b>--on-pull</b> <command> Execute command after installing or updating the module. The com-
|
||||||
mand is executed in the module root directory.
|
mand is executed in the module root directory.
|
||||||
<b>-d</b>|<b>--disabled</b> Don't initialize the module root or uninstall the module.
|
<b>-d</b>|<b>--disabled</b> Don't initialize the module root or uninstall the module.
|
||||||
|
|
|
@ -36,6 +36,9 @@ Per-module options:
|
||||||
Per-module-root options:
|
Per-module-root options:
|
||||||
<%= bold %>--if<%= normal %> <test> Will only initialize module root if specified test returns a zero
|
<%= 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.
|
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-
|
<%= bold %>--on-pull<%= normal %> <command> Execute command after installing or updating the module. The com-
|
||||||
mand is executed in the module root directory.
|
mand is executed in the module root directory.
|
||||||
<%= bold %>-d<%= normal %>|<%= bold %>--disabled<%= normal %> Don\'t initialize the module root or uninstall the module.
|
<%= 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
|
# Set values from options
|
||||||
while (( # > 0 )); do
|
while (( # > 0 )); do
|
||||||
case ${1} in
|
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
|
if (( # < 2 )); then
|
||||||
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Missing argument for zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage}
|
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Missing argument for zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage}
|
||||||
_zfailed=1
|
_zfailed=1
|
||||||
|
@ -165,6 +168,10 @@ Per-call initialization options:
|
||||||
shift
|
shift
|
||||||
_zifs[${zroot_dir}]=${1}
|
_zifs[${zroot_dir}]=${1}
|
||||||
;;
|
;;
|
||||||
|
--if-command)
|
||||||
|
shift
|
||||||
|
_zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
|
||||||
|
;;
|
||||||
-f|--fpath)
|
-f|--fpath)
|
||||||
shift
|
shift
|
||||||
zarg=${1}
|
zarg=${1}
|
||||||
|
|
14
zimfw.zsh
14
zimfw.zsh
|
@ -106,6 +106,9 @@ _zimfw_build_login_init() {
|
||||||
) ${ztarget}
|
) ${ztarget}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zeval() {
|
||||||
|
}
|
||||||
|
|
||||||
_zimfw_build() {
|
_zimfw_build() {
|
||||||
_zimfw_build_init && _zimfw_build_login_init && _zimfw_print 'Done with build.'
|
_zimfw_build_init && _zimfw_build_login_init && _zimfw_print 'Done with build.'
|
||||||
}
|
}
|
||||||
|
@ -148,6 +151,9 @@ Per-module options:
|
||||||
Per-module-root options:
|
Per-module-root options:
|
||||||
\E[1m--if\E[0m <test> Will only initialize module root if specified test returns a zero
|
\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.
|
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-
|
\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.
|
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.
|
\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
|
# Set values from options
|
||||||
while (( # > 0 )); do
|
while (( # > 0 )); do
|
||||||
case ${1} in
|
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
|
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}
|
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
|
_zfailed=1
|
||||||
|
@ -277,6 +283,10 @@ Per-call initialization options:
|
||||||
shift
|
shift
|
||||||
_zifs[${zroot_dir}]=${1}
|
_zifs[${zroot_dir}]=${1}
|
||||||
;;
|
;;
|
||||||
|
--if-command)
|
||||||
|
shift
|
||||||
|
_zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
|
||||||
|
;;
|
||||||
-f|--fpath)
|
-f|--fpath)
|
||||||
shift
|
shift
|
||||||
zarg=${1}
|
zarg=${1}
|
||||||
|
@ -444,7 +454,7 @@ _zimfw_compile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_info() {
|
_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
|
local zparam
|
||||||
for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do
|
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}
|
print -R ${(r.22....:.)zparam}${(P)zparam}
|
||||||
|
|
Loading…
Reference in a new issue