From 6d9b5a7d6db1815ea68bebf7cda7d1ded89c3392 Mon Sep 17 00:00:00 2001 From: LoneExile Date: Thu, 4 May 2023 01:07:39 +0700 Subject: [PATCH 1/5] feat(update): add flag (-a, --all) #123 --- zap.zsh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/zap.zsh b/zap.zsh index 13bc475..b29bad4 100644 --- a/zap.zsh +++ b/zap.zsh @@ -75,6 +75,14 @@ function _zap_update() { local _plugin _plug _status + if [[ "$1" == "-a" || "$1" == "--all" ]]; then + echo "\nUpdating All Plugins\n" + for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do + _pull "$ZAP_PLUGIN_DIR/$_plug" + done + return 0 + fi + function _check() { git -C "$1" remote update &> /dev/null case $(LANG=en_US git -C "$1" status -uno | grep -Eo '(ahead|behind|up to date)') in @@ -120,11 +128,11 @@ function _zap_help() { Usage: zap COMMANDS: - clean Remove unused plugins - help Show this help message - list List plugins - update Update plugins - version Show version information" + clean Remove unused plugins + help Show this help message + list List plugins + update [-a, --all] Update plugins + version Show version information" } function _zap_version() { @@ -144,7 +152,7 @@ function zap() { version "_zap_version" ) emulate -L zsh - [[ -z "$subcmds[$1]" ]] && { _zap_help; return 1 } || ${subcmds[$1]} + [[ -z "$subcmds[$1]" ]] && { _zap_help; return 1 } || ${subcmds[$1]} $2 } # vim: ft=zsh ts=4 et @@ -155,3 +163,4 @@ function zap() { # 13: Failed to checkout # 14: Failed to pull # 15: Nothing to remove + From f3c6e3a5f2110ddd1fc8ec4d1069c41bea27fa1e Mon Sep 17 00:00:00 2001 From: LoneExile Date: Thu, 4 May 2023 01:21:10 +0700 Subject: [PATCH 2/5] refactor: format code to "Zap style" --- zap.zsh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/zap.zsh b/zap.zsh index b29bad4..c76f128 100644 --- a/zap.zsh +++ b/zap.zsh @@ -75,13 +75,7 @@ function _zap_update() { local _plugin _plug _status - if [[ "$1" == "-a" || "$1" == "--all" ]]; then - echo "\nUpdating All Plugins\n" - for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do - _pull "$ZAP_PLUGIN_DIR/$_plug" - done - return 0 - fi + [[ "$1" == "-a" || "$1" == "--all" ]] && { echo "\nUpdating All Plugins\n"; for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do _pull "$ZAP_PLUGIN_DIR/$_plug"; done; return 0; } function _check() { git -C "$1" remote update &> /dev/null From 1188406f8fbc7a5f19ae7aa53028c57cf54d4c81 Mon Sep 17 00:00:00 2001 From: LoneExile Date: Thu, 4 May 2023 09:07:28 +0700 Subject: [PATCH 3/5] feat(update): add options all, self to update --- zap.zsh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/zap.zsh b/zap.zsh index c76f128..6171637 100644 --- a/zap.zsh +++ b/zap.zsh @@ -75,7 +75,8 @@ function _zap_update() { local _plugin _plug _status - [[ "$1" == "-a" || "$1" == "--all" ]] && { echo "\nUpdating All Plugins\n"; for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do _pull "$ZAP_PLUGIN_DIR/$_plug"; done; return 0; } + [[ $1 = "self" ]] && { _pull $ZAP_DIR; return } + [[ $1 == "all" ]] && { echo "\nUpdating All Plugins\n"; for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do _pull "$ZAP_PLUGIN_DIR/$_plug"; done; return 0; } function _check() { git -C "$1" remote update &> /dev/null @@ -119,14 +120,17 @@ function _zap_update() { function _zap_help() { echo "⚡ Zap - Help -Usage: zap +Usage: zap [options] COMMANDS: clean Remove unused plugins help Show this help message list List plugins - update [-a, --all] Update plugins - version Show version information" + update Update plugins + version Show version information + +OPTIONS: + all Update all out-of-date plugins (use with 'update' command)" } function _zap_version() { @@ -158,3 +162,5 @@ function zap() { # 14: Failed to pull # 15: Nothing to remove + + From 4baf2fb19faab63495c44467a54828bf524c64f4 Mon Sep 17 00:00:00 2001 From: LoneExile Date: Thu, 4 May 2023 09:09:53 +0700 Subject: [PATCH 4/5] feat(update): update usage zap_help --- zap.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zap.zsh b/zap.zsh index 6171637..4e7bdb4 100644 --- a/zap.zsh +++ b/zap.zsh @@ -130,7 +130,8 @@ COMMANDS: version Show version information OPTIONS: - all Update all out-of-date plugins (use with 'update' command)" + update self Update Zap itself + update all Update all plugins" } function _zap_version() { From d6416feae672041d01908324c10ebfb7e4cfc86b Mon Sep 17 00:00:00 2001 From: LoneExile Date: Thu, 4 May 2023 09:13:14 +0700 Subject: [PATCH 5/5] refactor: rm return value --- zap.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zap.zsh b/zap.zsh index 4e7bdb4..b91379c 100644 --- a/zap.zsh +++ b/zap.zsh @@ -76,7 +76,7 @@ function _zap_update() { local _plugin _plug _status [[ $1 = "self" ]] && { _pull $ZAP_DIR; return } - [[ $1 == "all" ]] && { echo "\nUpdating All Plugins\n"; for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do _pull "$ZAP_PLUGIN_DIR/$_plug"; done; return 0; } + [[ $1 == "all" ]] && { echo "\nUpdating All Plugins\n"; for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do _pull "$ZAP_PLUGIN_DIR/$_plug"; done; return } function _check() { git -C "$1" remote update &> /dev/null