refactor: rename funcs

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
This commit is contained in:
Vladislav Doster 2022-11-20 10:59:12 -06:00
parent 1f761fa80c
commit 01b634ff74
7 changed files with 33 additions and 31 deletions

View file

@ -1,7 +1,7 @@
# Copyright (c) 2019 Sebastian Gniazdowski
# License MIT
#
# FUNCTION: .za-bgn-bin-or-src-function-body
# FUNCTION: -za-rust::bin-or-src-function-body
# Returns the body of the function wrapping a binary
local name="$2" bin="$3" dir="$4"

View file

@ -19,10 +19,10 @@ fi
local nl=$'\n'
# FUNCTION: .zinit-annex-rust-download-file-stdout [[[
# FUNCTION: __za-rust::download-file-stdout [[[
# Downloads file to stdout. Supports following backend commands:
# curl, wget, lftp, lynx. Used by snippet loading.
.zinit-annex-rust-download-file-stdout() {
__za-rust::download-file-stdout() {
local url="$1" restart="$2"
setopt localoptions localtraps
@ -53,7 +53,7 @@ local nl=$'\n'
elif type lftp 2>/dev/null 1>&2; then
command lftp -c "cat $url" || return 1
else
.zinit-annex-rust-download-file-stdout "$url" "1"
__za-rust::download-file-stdout "$url" "1"
return $?
fi
fi
@ -62,16 +62,16 @@ local nl=$'\n'
} # ]]]
if (( ${+ICE[rustup]} )) {
if [[ $hook = *atclone-<-> ]] {
if [[ $hook = *clone-<-> ]] {
(
builtin cd -q "$dir" || {
print -P -- "%F{38}rust annex: %F{198}An internal error, please report at: %F{220}https://github.com/zdharma-continuum/zinit-annex-rust/issues%F{198}%f"
return 1
}
command mkdir -p bin rustup
.zinit-annex-rust-download-file-stdout 'https://sh.rustup.rs' 0 >! bin/rustup-init || \
__za-rust::download-file-stdout 'https://sh.rustup.rs' 0 >! bin/rustup-init || \
{
.zinit-annex-rust-download-file-stdout 'https://sh.rustup.rs' 1 >! bin/rustup-init || \
__za-rust::download-file-stdout 'https://sh.rustup.rs' 1 >! bin/rustup-init || \
{
print -P -- "%F{38}rust annex: %F{198}Couldn't download the %F{220}rustup.rs%F{198} installer%f"
return 0
@ -140,7 +140,7 @@ if [[ -n "${ICE[cargo]}" ]] {
}
(( ${#cargos} )) && {
if [[ "$hook" = *atclone-<-> ]]; then
if [[ "$hook" = *clone-<-> ]]; then
print -P -- "%F{38}rust annex: %F{154}Installing the requested crates...%f"
if (( ${+ICE[rustup]} )) {
local -x CARGO_HOME="$dir" RUSTUP_HOME="$dir/rustup" PATH="$dir/bin:$PATH"
@ -148,7 +148,7 @@ if [[ -n "${ICE[cargo]}" ]] {
} else {
cargo install --force --root "$dir" "${cargos[@]}"
}
elif [[ "$hook" = *atpull-<-> ]]; then
elif [[ "$hook" = *pull-<-> ]]; then
if (( !OPTS[opt_-q,--quiet] )) {
print -P -- "%F{38}rust annex: %F{154}Updating the installed crates...%f"
}
@ -215,7 +215,7 @@ if [[ -n "${ICE[cargo]}" ]] {
fnam="${bin_pkg_dst[3]:-${bin_pkg_dst[1]:t}}"
local file="$ZPFX/bin/$fnam"
.za-rust-bin-or-src-function-body 0 \
-za-rust::bin-or-src-function-body 0 \
"$fnam" "$target_binary" "$dir" \
"${${(M)set_rust_home_vars:#1}:-${+ICE[rustup]}}" \
"$set_gem_home" "$set_node_path" "$set_cwd" \
@ -227,8 +227,8 @@ if [[ -n "${ICE[cargo]}" ]] {
if [[ -x $file ]]; then
if (( !OPTS[opt_-q,--quiet] )); then
if [[ $hook == atclone-<-> || $ZINIT[annex-multi-flag:pull-active] -ge 1 ]]; then
+zinit-message "{pre}rust annex: {data2}${${hook:#*atclone-<->}:+Re-}Created the {file}$fnam{data2} shim.{rst}"
if [[ $hook == clone-<-> || $ZINIT[annex-multi-flag:pull-active] -ge 1 ]]; then
+zinit-message "{pre}rust annex: {data2}${${hook:#*clone-<->}:+Re-}Created the {file}$fnam{data2} shim.{rst}"
fi
fi
else

View file

@ -8,32 +8,34 @@
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
autoload .za-rust-bin-or-src-function-body \
za-rust-atload-handler za-rust-atclone-handler \
za-rust-atpull-handler za-rust-help-handler \
za-rust-atdelete-handler
autoload -Uz \
-za-rust::bin-or-src-function-body \
:za-rust::clone-handler \
:za-rust::delete-handler \
:za-rust::load-handler \
:za-rust::pull-handler \
:za-rust::help-handler
# An empty stub to fill the help handler fields
za-rust-help-null-handler() { :; }
:za-rust::help-null-handler() { :; }
@zinit-register-annex "zinit-annex-rust" \
hook:atload-40 \
za-rust-atload-handler \
za-rust-help-handler \
"rustup|cargo''" # also register new ices
hook:load-40 \
:za-rust::load-handler \
:za-rust::help-handler \
"rustup|cargo''" # also register new ices
@zinit-register-annex "zinit-annex-rust" \
hook:atclone-40 \
za-rust-atclone-handler \
za-rust-help-null-handler
hook:clone-40 \
:za-rust::clone-handler \
:za-rust::help-null-handler
@zinit-register-annex "zinit-annex-rust" \
hook:\%atpull-40 \
za-rust-atclone-handler \
za-rust-help-null-handler
hook:\%pull-40 \
:za-rust::clone-handler \
:za-rust::help-null-handler
@zinit-register-annex "zinit-annex-rust" \
hook:atdelete-40 \
za-rust-atdelete-handler \
za-rust-help-null-handler
hook:delete-40 \
:za-rust::delete-handler \
:za-rust::help-null-handler