mirror of
https://github.com/zplug/zplug
synced 2025-08-30 17:50:43 +02:00
99 lines
3.4 KiB
Bash
99 lines
3.4 KiB
Bash
#!/bin/zsh
|
|
|
|
__import "core/core"
|
|
__import "print/print"
|
|
__import "zplug/external"
|
|
__import "zplug/variables"
|
|
|
|
local name
|
|
local tag key val
|
|
local -a tags
|
|
local -i max=0
|
|
local -a re_tags
|
|
|
|
tags=( ${(s/, /)@:gs/, */, } )
|
|
name="${tags[1]}"
|
|
tags[1]=()
|
|
|
|
# In the case of "from:local", it accepts multiple slashes
|
|
if [[ ! $name =~ [~$/] ]] && [[ ! $name =~ "^[^/]+/[^/]+$" ]]; then
|
|
__zplug::print::print::die "[zplug] ERROR: ${(qq)name} is invalid package name\n"
|
|
return 1
|
|
fi
|
|
|
|
# DEPRECATED: pipe
|
|
if [[ -p /dev/stdin ]]; then
|
|
__zplug::print::print::die "[zplug] $fg[red]${(%):-"%U"}WARNING${(%):-"%u"}$reset_color: pipe syntax is deprecated!\n"
|
|
__zplug::print::print::die "[zplug] Please use '$fg[blue]on$reset_color' tag instead.\n"
|
|
return 1
|
|
fi
|
|
|
|
if __zplug::core::core::is_cli; then
|
|
if __zplug::core::core::zpluged "$name"; then
|
|
__zplug::print::print::die "[zplug] $name: already managed\n"
|
|
return 1
|
|
else
|
|
# Add to the external file
|
|
__zplug::zplug::external::generate \
|
|
"zplug ${(qqq)name}${tags[@]:+", ${(j:, :)${(q)tags[@]}}"}"
|
|
fi
|
|
fi
|
|
|
|
# Process the duplication of key
|
|
if __zplug::core::core::zpluged; then
|
|
for key in "${(k)zplugs[@]}"
|
|
do
|
|
if [[ $key =~ ^$name@*$ ]] && (( $max < $#key )); then
|
|
max=$#key
|
|
name="${key}@"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Reconstruct the tag information
|
|
for tag in "${tags[@]}"
|
|
do
|
|
key=${${(s.:.)tag}[1]}
|
|
val=${${(s.:.)tag}[2]}
|
|
|
|
if (( $_zplug_tag_pattern[(I)${key}] )); then
|
|
case "$key" in
|
|
"of")
|
|
key="use"
|
|
__zplug::print::print::die "[zplug] $fg[red]${(%):-"%U"}WARNING${(%):-"%u"}$reset_color: '$fg[blue]of$reset_color' tag is deprecated. "
|
|
__zplug::print::print::die "Please use '$fg[blue]use$reset_color' tag instead ($fg[green]${name:gs:@::}$reset_color).\n"
|
|
;;
|
|
"file")
|
|
key="rename-to"
|
|
__zplug::print::print::die "[zplug] $fg[red]${(%):-"%U"}WARNING${(%):-"%u"}$reset_color: '$fg[blue]file$reset_color' tag is deprecated. "
|
|
__zplug::print::print::die "Please use '$fg[blue]rename-to$reset_color' tag instead ($fg[green]${name:gs:@::}$reset_color).\n"
|
|
;;
|
|
"commit")
|
|
key="at"
|
|
__zplug::print::print::die "[zplug] $fg[red]${(%):-"%U"}WARNING${(%):-"%u"}$reset_color: '$fg[blue]commit$reset_color' tag is deprecated. "
|
|
__zplug::print::print::die "Please use '$fg[blue]at$reset_color' tag instead ($fg[green]${name:gs:@::}$reset_color).\n"
|
|
;;
|
|
"do")
|
|
key="hook-build"
|
|
__zplug::print::print::die "[zplug] $fg[red]${(%):-"%U"}WARNING${(%):-"%u"}$reset_color: '$fg[blue]do$reset_color' tag is deprecated. "
|
|
__zplug::print::print::die "Please use '$fg[blue]hook-build$reset_color' tag instead ($fg[green]${name:gs:@::}$reset_color).\n"
|
|
return 1
|
|
;;
|
|
"from")
|
|
if __zplug::core::core::is_external "$val"; then
|
|
source $ZPLUG_ROOT/base/sources/$val.zsh
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
# Reconstruct
|
|
re_tags+=("$key:$val")
|
|
else
|
|
__zplug::print::print::die "[zplug] $tag: $key is invalid tag name\n"
|
|
return 1
|
|
fi
|
|
done
|
|
|
|
# Add to zplugs
|
|
zplugs+=("$name" "${(j:, :)re_tags[@]:-}")
|