From 01b634ff74ddbdfee8ed7be3f77e40c3bd9de06b Mon Sep 17 00:00:00 2001 From: Vladislav Doster Date: Sun, 20 Nov 2022 10:59:12 -0600 Subject: [PATCH] refactor: rename funcs Signed-off-by: Vladislav Doster --- ...body => -za-rust::bin-or-src-function-body | 2 +- ...atclone-handler => :za-rust::clone-handler | 22 +++++----- ...delete-handler => :za-rust::delete-handler | 0 ...t-atload-handler => :za-rust::help-handler | 0 ...t-atpull-handler => :za-rust::load-handler | 0 ...ust-help-handler => :za-rust::pull-handler | 0 z-a-rust.plugin.zsh | 40 ++++++++++--------- 7 files changed, 33 insertions(+), 31 deletions(-) rename .za-rust-bin-or-src-function-body => -za-rust::bin-or-src-function-body (96%) rename za-rust-atclone-handler => :za-rust::clone-handler (92%) rename za-rust-atdelete-handler => :za-rust::delete-handler (100%) rename za-rust-atload-handler => :za-rust::help-handler (100%) rename za-rust-atpull-handler => :za-rust::load-handler (100%) rename za-rust-help-handler => :za-rust::pull-handler (100%) diff --git a/.za-rust-bin-or-src-function-body b/-za-rust::bin-or-src-function-body similarity index 96% rename from .za-rust-bin-or-src-function-body rename to -za-rust::bin-or-src-function-body index 6200cd2..e6e072a 100644 --- a/.za-rust-bin-or-src-function-body +++ b/-za-rust::bin-or-src-function-body @@ -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" diff --git a/za-rust-atclone-handler b/:za-rust::clone-handler similarity index 92% rename from za-rust-atclone-handler rename to :za-rust::clone-handler index 8cdd132..1a7e9f3 100644 --- a/za-rust-atclone-handler +++ b/:za-rust::clone-handler @@ -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 diff --git a/za-rust-atdelete-handler b/:za-rust::delete-handler similarity index 100% rename from za-rust-atdelete-handler rename to :za-rust::delete-handler diff --git a/za-rust-atload-handler b/:za-rust::help-handler similarity index 100% rename from za-rust-atload-handler rename to :za-rust::help-handler diff --git a/za-rust-atpull-handler b/:za-rust::load-handler similarity index 100% rename from za-rust-atpull-handler rename to :za-rust::load-handler diff --git a/za-rust-help-handler b/:za-rust::pull-handler similarity index 100% rename from za-rust-help-handler rename to :za-rust::pull-handler diff --git a/z-a-rust.plugin.zsh b/z-a-rust.plugin.zsh index b5bc8f2..2699409 100644 --- a/z-a-rust.plugin.zsh +++ b/z-a-rust.plugin.zsh @@ -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