mirror of
https://github.com/zplug/zplug
synced 2025-08-30 01:30:43 +02:00
- Cutting out the tag-related code in each external files - like `commands` and `options` - All developers have to do simply add tag file beginning(ending) in two underscores
91 lines
2.0 KiB
Bash
91 lines
2.0 KiB
Bash
#!/bin/zsh
|
|
|
|
__import "core/core"
|
|
__import "print/print"
|
|
|
|
local arg filter repo
|
|
local is_force is_select=false
|
|
local -a args repos remove_args
|
|
local -A zspec
|
|
local -i ret=0
|
|
|
|
while (( $# > 0 ))
|
|
do
|
|
arg="$1"
|
|
case "$arg" in
|
|
--force)
|
|
is_force=true
|
|
;;
|
|
--select)
|
|
is_select=true
|
|
;;
|
|
-*|--*)
|
|
__zplug::print::print::die "[zplug] $arg: Unknown option\n"
|
|
return 1
|
|
;;
|
|
*)
|
|
args+=("$arg")
|
|
esac
|
|
shift
|
|
done
|
|
|
|
filter="$(__zplug::core::core::get_filter "$ZPLUG_FILTER")"
|
|
if $is_select; then
|
|
args=(${(@f)"$(echo "${(Fk)zplugs[@]}" | eval "$filter")"})
|
|
if (( $#args == 0 )); then
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
if (( $#args == 0 )); then
|
|
repos=( "$ZPLUG_HOME"/repos/*/*(N-/) )
|
|
for repo in "${repos[@]}"
|
|
do
|
|
if ! __zplug::core::core::zpluged "${repo:h:t}/${repo:t}"; then
|
|
remove_args+=("$repo")
|
|
fi
|
|
done
|
|
else
|
|
for arg in "${args[@]}"
|
|
do
|
|
__parser__ "$arg"
|
|
zspec=( "${reply[@]}" )
|
|
if [[ -d $zspec[dir] ]]; then
|
|
case "$zspec[from]" in
|
|
"oh-my-zsh")
|
|
remove_args+=("$ZPLUG_HOME/repos/$_ZPLUG_OHMYZSH")
|
|
;;
|
|
*)
|
|
remove_args+=("$zspec[dir]")
|
|
;;
|
|
esac
|
|
else
|
|
__zplug::print::print::die "[zplug] $arg: no such package\n"
|
|
ret=1
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Remove packages from $ZPLUG_HOME/repos
|
|
for repo in "${remove_args[@]}"
|
|
do
|
|
__zplug::print::print::put "${${is_force:+"Removed"}:-"Remove? (y/N)"} ${(qq)repo} "
|
|
if ${(z)is_force:-"read -q"}; then
|
|
rm -rf "$repo"
|
|
rmdir "${repo:h}"
|
|
fi &>/dev/null
|
|
__zplug::print::print::put "\n"
|
|
done
|
|
|
|
# Remove packages from $zplugs
|
|
for repo in "${(k)zplugs[@]}"
|
|
do
|
|
__parser__ "$repo"
|
|
zspec=( "${reply[@]}" )
|
|
if [[ ! -d $zspec[dir] ]]; then
|
|
unset "zplugs[$repo]"
|
|
fi
|
|
done
|
|
|
|
return $ret
|