Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add install arguments to not set up {,f}path #271

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions completions/_znap
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ case $words[1] in
( clone )
_arguments : '*:remote repository:_urls'
;;
( compdef )
_arguments : ':function name:' ': :_default'
;;
( compile )
_arguments : ': :_default'
;;
Expand All @@ -42,7 +39,10 @@ case $words[1] in
_arguments : ': :->repos' ':pattern:'
;;
( install )
_arguments : '*:remote repository:_urls'
_arguments : \
"--no-fpath[don't update fpath with completions or functions]" \
"--no-path[don't update PATH with binaries]" \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, znap --no-fpath --no-path <url> would be basically be a no-op?

'*:remote repository:_urls'
;;
( multi )
_arguments : ': :_default'
Expand Down
26 changes: 16 additions & 10 deletions functions/.znap.install
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/zsh
# install executables & completion functions
# args: <repo> ...
# args: <repo> [--no-path] [--no-fpath] ...
emulate -L zsh; setopt $_znap_opts
zmodload -Fa zsh/files b:zf_ln b:zf_mkdir

Expand All @@ -10,12 +10,14 @@ if (( $# < 1 )); then
return $(( sysexits[(i)USAGE] + 63 ))
fi

local -A opts
zparseopts -A opts -E -D -- -no-path -no-fpath

.znap.clone $@ ||
return

local REPLY=
private -aU funcfiles=()
private bindir=~/.local/bin
private d='' link='' pat='[[:alnum:]][[:alnum:]_-]#[[:alnum:]]'

local -a repos=()
Expand All @@ -26,14 +28,18 @@ private repo=
for repo in $repos; do
repo=~[$repo]

path=(
$repo/{,bin/}$~pat(N*:h)
$path[@]
)
fpath=(
$repo/{,{[Cc]ompletions,[Ss]rc,zsh}/($~pat/)#}_$~pat(N^/:h)
$fpath
)
if ! (( $+opts[--no-path] )) ; then
path=(
$repo/{,bin/}$~pat(N*:h)
$path[@]
)
fi
if ! (( $+opts[--no-fpath] )) ; then
fpath=(
$repo/{,{[Cc]ompletions,[Ss]rc,zsh}/($~pat/)#}_$~pat(N^/:h)
$fpath
)
fi

funcfiles=( $repo/{,[Ff]unctions}/($~pat/)#}$~pat(N^/) )
(( $#funcfiles )) &&
Expand Down
6 changes: 3 additions & 3 deletions functions/znap
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ fi
private _P__cmd=$1
shift

local -A opts_pre=() opts_post=()
zparseopts -A opts_post -D -- h -help
local -A opts_post=()
zparseopts -A opts_post -E -D -- h -help

private _P__func=.znap.$_P__cmd
if [[ -v functions[$_P__func] ]]; then
if (( ${#opts_pre} || ${#opts_post} )); then
if (( ${#opts_post} )); then
.znap.help $_P__cmd
else
$_P__func $@
Expand Down