Skip to content

Commit 702cdb0

Browse files
committed
Implement antidote2 path
1 parent ce69b2e commit 702cdb0

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

functions/antidote-path

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,8 @@
2121
return 1
2222
fi
2323

24-
local bundle bundledir
25-
local -a results=()
26-
for bundle in $bundles; do
27-
if [[ $bundle == '$'* ]] && [[ $bundle != *'('* ]] && [[ $bundle != *';'* ]]; then
28-
bundle=$(eval print $bundle)
29-
fi
30-
bundledir=$(__antidote_bundle_dir $bundle)
31-
if [[ ! -d $bundledir ]]; then
32-
print -ru2 "antidote: error: $bundle does not exist in cloned paths"
33-
return 1
34-
else
35-
results+=("$bundledir")
36-
fi
24+
local bundle
25+
for bundle in "${bundles[@]}"; do
26+
antidote2 path "${bundle}"
3727
done
38-
print -l -- $results
3928
#}

functions/antidote2.zsh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,9 @@ antidote_path() {
597597
return 1
598598
fi
599599

600+
# If a real path was provided, then that's the path.
601+
[[ -e "$1" && "$1" == /* ]] && printf '%s\n' "$1" && return 0
602+
600603
# Figure out the bundle directory.
601604
bundle_dir="$(_bundledir "$1")" || ret=1
602605
[[ "$ret" -eq 0 ]] && bundle_path="$(antidote_home)/${bundle_dir}"

tests/test_cmd_path.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $ANTIDOTE_HOME/foo/bar
2424
```zsh
2525
% antidote path bar/foo &>/dev/null #=> --exit 1
2626
% antidote path bar/foo; err=$?
27-
antidote: error: bar/foo does not exist in cloned paths
27+
antidote path: error: 'bar/foo' does not exist in cloned paths
2828
% echo $err
2929
1
3030
%
@@ -46,7 +46,7 @@ $ANTIDOTE_HOME/ohmy/ohmy
4646

4747
```zsh
4848
% ZSH_CUSTOM=$ZDOTDIR/custom
49-
% antidote path '$ZSH_CUSTOM/plugins/myplugin' | subenv
49+
% antidote path $ZSH_CUSTOM/plugins/myplugin | subenv
5050
$HOME/.zsh/custom/plugins/myplugin
5151
%
5252
```

0 commit comments

Comments
 (0)