Skip to content

Commit

Permalink
feat: add list command. align numbered lists (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
wintermi authored Feb 22, 2023
1 parent 5ecf87a commit 3564bef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions completion/_zap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
local -a subcmds=(
"clean:Remove unused plugins"
"help:Show help informations"
"list:List plugins"
"update:Update plugins"
"version:Show version information"
)
Expand Down
19 changes: 16 additions & 3 deletions zap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function _pull() {

function _zap_clean() {
typeset -a unused_plugins=()
echo "⚡ Zap - Clean\n"
for plugin in "$ZAP_PLUGIN_DIR"/*; do
[[ "$ZAP_INSTALLED_PLUGINS[(Ie)${plugin:t}]" -eq 0 ]] && unused_plugins+=("${plugin:t}")
done
Expand All @@ -62,11 +63,19 @@ function _zap_clean() {
done
}

function _zap_list() {
local _plugin
echo "⚡ Zap - List\n"
for _plugin in ${ZAP_INSTALLED_PLUGINS[@]}; do
printf '%4s 🔌 %s\n' $ZAP_INSTALLED_PLUGINS[(Ie)$_plugin] $_plugin
done
}

function _zap_update() {
local _plugin _plug
echo "0 ⚡ Zap"
echo "⚡ Zap - Update\n\n 0 ⚡ Zap"
for _plugin in ${ZAP_INSTALLED_PLUGINS[@]}; do
echo "$ZAP_INSTALLED_PLUGINS[(Ie)$_plugin] 🔌 $_plugin"
printf '%4s 🔌 %s\n' $ZAP_INSTALLED_PLUGINS[(Ie)$_plugin] $_plugin
done
echo -n "\n🔌 Plugin Number | (a) All Plugins | (0) ⚡ Zap Itself: " && read _plugin
case $_plugin in
Expand All @@ -86,11 +95,14 @@ function _zap_update() {
}

function _zap_help() {
echo "Usage: zap <command>
echo "⚡ Zap - Help
Usage: zap <command>
COMMANDS:
clean Remove unused plugins
help Show this help message
list List plugins
update Update plugins
version Show version information"
}
Expand All @@ -105,6 +117,7 @@ function zap() {
typeset -A subcmds=(
clean "_zap_clean"
help "_zap_help"
list "_zap_list"
update "_zap_update"
version "_zap_version"
)
Expand Down

0 comments on commit 3564bef

Please sign in to comment.