diff --git a/za-patch-dl-handler b/:za-patch-dl::file-handler similarity index 84% rename from za-patch-dl-handler rename to :za-patch-dl::file-handler index a9c120f..c76cd62 100644 --- a/za-patch-dl-handler +++ b/:za-patch-dl::file-handler @@ -1,3 +1,8 @@ +#!/usr/bin/env zsh +# +# Copyright (c) 2016-2021 Sebastian Gniazdowski and contributors +# Copyright (c) 2021-2022 zdharma-continuum and contributors + emulate -RL zsh setopt extendedglob noshortloops typesetsilent warncreateglobal @@ -7,10 +12,10 @@ else local type="$1" url="$2" id_as="$3" dir="$4" fi -# FUNCTION: .zinit-annex-patch-dl-download-file-stdout {{{ +# FUNCTION: :za-patch-dl::get-file-handler {{{ # Downloads file to stdout. Used by snippet loading. # Supports following backend commands: curl, wget, lftp, lynx. -.zinit-annex-patch-dl-download-file-stdout() { +:za-patch-dl::get-file-handler() { local url="$1" restart="$2" setopt localoptions localtraps @@ -40,7 +45,7 @@ fi elif type lftp 2>/dev/null 1>&2; then command lftp -c "cat $url" || return 1 else - .zinit-annex-patch-dl-download-file-stdout "$url" "1" + :za-patch-dl::get-file-handler "$url" "1" return $? fi fi @@ -75,8 +80,8 @@ if [[ -n ${ICE[dl]} && ${ICE[dl]} != ink=[-/[:alnum:]]* ]]; then local ret=0 - if ! .zinit-annex-patch-dl-download-file-stdout "${srcdst[1]}" >! "$tdir/$tl"; then - if ! .zinit-annex-patch-dl-download-file-stdout "${srcdst[1]}" 1 >! "$tdir/$tl"; then + if ! :za-patch-dl::get-file-handler "${srcdst[1]}" >! "$tdir/$tl"; then + if ! :za-patch-dl::get-file-handler "${srcdst[1]}" 1 >! "$tdir/$tl"; then print -P -- "%F{38}[patch-dl annex]: %F{160}Failed to download the URL %F{220}${srcdst[1]}%f" ret=1 fi @@ -110,4 +115,4 @@ if [[ -n "${ICE[patch]}" ]]; then } fi -# vim:ft=zsh:sw=2:sts=2:et +# vim: set expandtab filetype=zsh shiftwidth=2 softtabstop=2 tabstop=2: diff --git a/z-a-patch-dl.plugin.zsh b/z-a-patch-dl.plugin.zsh index 0c5223b..82377c7 100644 --- a/z-a-patch-dl.plugin.zsh +++ b/z-a-patch-dl.plugin.zsh @@ -4,20 +4,24 @@ 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" -autoload -Uz za-patch-dl-handler +autoload -Uz \ + :za-patch-dl::help-handler \ + :za-patch-dl::file-handler # An empty stub to fill the help handler fields -za-patch-dl-help-null-handler() { :; } +:za-patch-dl::help-handler() { :; } # Register !atclone hook -@zinit-register-annex "zinit-annex-patch-dl" hook:\!atclone-20 \ - za-patch-dl-handler \ - za-patch-dl-help-null-handler \ +@zinit-register-annex "zinit-annex-patch-dl" \ + hook:\!atclone-20 \ + :za-patch-dl::file-handler \ + :za-patch-dl::help-handler \ "dl''|patch''" # register a new ice-mod: test'' # Register !atpull hook -@zinit-register-annex "zinit-annex-patch-dl" hook:\!atpull-20 \ - za-patch-dl-handler \ - za-patch-dl-help-null-handler +@zinit-register-annex "zinit-annex-patch-dl" \ + hook:\!atpull-20 \ + :za-patch-dl::file-handler \ + :za-patch-dl::help-handler -# vim:ft=zsh:sw=2:sts=2:et +# vim: set expandtab filetype=zsh shiftwidth=2 softtabstop=2 tabstop=2: