mirror of
https://github.com/zdharma-continuum/zinit.git
synced 2026-09-10 15:46:36 -04:00
fix: plugins command correctly handles keyword argument (#626)
This commit is contained in:
parent
9ce9ec6367
commit
f26d387e51
|
|
@ -37,12 +37,17 @@
|
|||
}
|
||||
|
||||
@test 'plugins' {
|
||||
run zinit plugins
|
||||
assert $output contains 'Plugins'
|
||||
assert $output contains 'Unloaded: '
|
||||
assert $output contains 'Loaded: '
|
||||
run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit plugins)
|
||||
assert $state equals 0
|
||||
assert $output contains "==> 5 Plugins"
|
||||
assert $output contains 'Loaded: L | Unloaded: U'
|
||||
}
|
||||
@test 'plugins with keyword' {
|
||||
run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit plugins zdharma)
|
||||
assert $state equals 0
|
||||
assert $output contains "==> 4 Plugins matching 'zdharma'"
|
||||
}
|
||||
|
||||
@test 'help' {
|
||||
for cmd in 'help' '-h' '--help'; do
|
||||
run zinit $cmd
|
||||
|
|
|
|||
|
|
@ -1563,29 +1563,29 @@ print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}"
|
|||
done
|
||||
} # ]]]
|
||||
# FUNCTION: .zinit-list-plugins [[[
|
||||
# Lists loaded plugins (subcommands list, lodaded)
|
||||
.zinit-list-plugins() {
|
||||
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
|
||||
# Lists loaded plugins
|
||||
.zinit-list-plugins () {
|
||||
builtin emulate -LR zsh
|
||||
setopt extended_glob warn_create_global typeset_silent no_short_loops
|
||||
typeset -a filtered
|
||||
local keyword="$1"
|
||||
keyword="${keyword## ##}"
|
||||
keyword="${keyword%% ##}"
|
||||
if [[ -n "$keyword" ]]; then
|
||||
+zi-log "{i} Installed plugins matching {info}$keyword{rst}:"
|
||||
filtered=( "${(M)ZINIT[@]:#STATES__*$keyword*}" )
|
||||
else
|
||||
filtered=(${${(M)${(k)ZINIT[@]}:##STATES__*}//[A-Z]*__/})
|
||||
fi
|
||||
local i
|
||||
+zi-log '{m} {b}Plugins{rst}'
|
||||
for i in "${(o)filtered[@]}"; do
|
||||
[[ "$i" = "local/zinit" ]] && continue
|
||||
local is_loaded='{error}U'
|
||||
(( ZINIT[STATES__${i}] )) && is_loaded="{happy}L"
|
||||
+zi-log -C2 -- $is_loaded{rst} $i
|
||||
done
|
||||
+zi-log -- '{nl}Loaded: {happy}L{rst} | Unloaded: {error}U{rst}'
|
||||
local keyword="${${${1}## ##}%% ##}"
|
||||
if [[ -n "$keyword" ]]; then
|
||||
+zi-log "{dbg} ${(qqq)1} -> ${(qqq)keyword}{rst}"
|
||||
filtered=(${${(k)ZINIT[(I)STATES__*${keyword}*~*(local/zinit)*]}//[A-Z]*__/})
|
||||
+zi-log "{m} ${#filtered} {b}Plugins{rst} matching '{glob}${keyword}{rst}'"
|
||||
else
|
||||
filtered=(${${(M)${(k)ZINIT[@]}:##STATES__*~*local/zinit*}//[A-Z]*__/})
|
||||
+zi-log "{m} ${#filtered} {b}Plugins{rst}"
|
||||
fi
|
||||
local i
|
||||
local -i idx=1
|
||||
for i in "${(o)filtered[@]}"; do
|
||||
local is_loaded='{error}U'
|
||||
(( ZINIT[STATES__${i}] )) && is_loaded="{happy}L"
|
||||
+zi-log "$(print -f "%2d %s %s\n" ${idx} ${is_loaded} {b}${(D)i//[%]/}{rst})"
|
||||
(( idx+=1 ))
|
||||
done
|
||||
+zi-log -- '{nl}Loaded: {happy}L{rst} | Unloaded: {error}U{rst}'
|
||||
} # ]]]
|
||||
# FUNCTION: .zinit-list-snippets [[[
|
||||
.zinit-list-snippets() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue