Skip to content

Commit

Permalink
Merge pull request #494 from zdharma-continuum/57-allow-deleting-mult…
Browse files Browse the repository at this point in the history
…iple-plugins-in-one-command

fix: delete multiple plugins at once

- `delete` subcommand can now take multiple arguments
- improved logic for `--all`, `--clean` flags
- improved log output
- now cleans up broken symlinks
  • Loading branch information
vladdoster authored Apr 2, 2023
2 parents 0bdf9ea + 3802893 commit 6a5d2b1
Show file tree
Hide file tree
Showing 9 changed files with 252 additions and 199 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
echo "" >> $GITHUB_STEP_SUMMARY # this is a blank line
if ! git --no-pager diff --exit-code; then
echo "::error:: Z-shelldocs are out-of-date." >> $GITHUB_STEP_SUMMARY
echo "To regenerate, run `make doc`" >> $GITHUB_STEP_SUMMARY
echo 'To regenerate, run `make doc`' >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "::notice:: Z-shelldocs are up-to-date." >> $GITHUB_STEP_SUMMARY
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ jobs:
- name: "annexes"
run: zunit run tests/annexes.zunit

- name: "commands"
run: zunit run tests/commands.zunit

- name: "gh-r"
run: zunit run --fail-fast --verbose tests/gh-r.zunit

Expand Down
2 changes: 1 addition & 1 deletion _zinit
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ _zinit_delete(){
'--quiet[Turn off messages from the operation]' \
'--yes[Automatically confirm any yes/no prompts]' \
+ '(operation)' \
'1:installed:__zinit_installed' \
'*::installed:__zinit_installed' \
{-a,--all}'[Delete all plugins and snippets]' \
{-c,--clean}'[Delete only the currently-not loaded plugins and snippets]'
} # ]]]
Expand Down
47 changes: 33 additions & 14 deletions doc/zsdoc/zinit-autoload.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ FUNCTIONS
.zinit-module
.zinit-pager
.zinit-prepare-readlink
.zinit-prompt
.zinit-recall
.zinit-recently
.zinit-restore-extendedglob
Expand Down Expand Up @@ -398,9 +399,7 @@ Has 17 line(s). Calls functions:
Uses feature(s): _eval_, _read_
Called by:
.zinit-delete
Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
.zinit-create
~~~~~~~~~~~~~
Expand Down Expand Up @@ -431,26 +430,24 @@ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
____
Deletes plugin's or snippet's directory (in Zinit's home directory).
Deletes a plugin or snippet and related files and hooks.
User-action entry point.
$1 - snippet URL or plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
$2 - plugin (only when $1 - i.e. user - given)
$1 - snippet url or plugin
____
Has 99 line(s). Calls functions:
Has 107 line(s). Calls functions:
.zinit-delete
|-- zinit-side.zsh/.zinit-compute-ice
|-- zinit.zsh/+zinit-message
|-- zinit.zsh/+zinit-prehelp-usage-message
|-- zinit.zsh/.zinit-any-to-user-plugin
`-- zinit.zsh/.zinit-parse-opts
`-- zinit.zsh/zinit
Uses feature(s): _setopt_
Uses feature(s): _setopt_, _zmodload_, _zparseopts_
Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
Called by:
zinit.zsh/zinit
.zinit-diff-env-compute
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -886,6 +883,26 @@ Called by:
.zinit-clear-completions
.zinit-show-completions
.zinit-prompt
~~~~~~~~~~~~~
____
Prompt user to confirm
$1 - prompt
$REPLY - 0 or 1
____
Has 4 line(s). Doesn't call other functions.
Uses feature(s): _read_
Called by:
.zinit-delete
.zinit-recall
~~~~~~~~~~~~~
Expand Down Expand Up @@ -949,7 +966,9 @@ Has 17 line(s). Calls functions:
Uses feature(s): _eval_
Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
Called by:
.zinit-delete
.zinit-save-set-extendedglob
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion doc/zsdoc/zinit-install.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ ____
`#compdef <names ...>'
____
Has 573 line(s). Doesn't call other functions.
Has 549 line(s). Doesn't call other functions.
Uses feature(s): _autoload_, _bindkey_, _compdef_, _compdump_, _eval_, _read_, _setopt_, _unfunction_, _zle_, _zstyle_
Expand Down
15 changes: 8 additions & 7 deletions doc/zsdoc/zinit.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ DETAILS
Script Body
~~~~~~~~~~~
Has 252 line(s). Calls functions:
Has 244 line(s). Calls functions:
Script-Body
|-- +zinit-message
Expand All @@ -115,6 +115,7 @@ Has 252 line(s). Calls functions:
|   |-- zinit-autoload.zsh/.zinit-clear-completions
|   |-- zinit-autoload.zsh/.zinit-compile-uncompile-all
|   |-- zinit-autoload.zsh/.zinit-compiled
|   |-- zinit-autoload.zsh/.zinit-delete
|   |-- zinit-autoload.zsh/.zinit-help
|   |-- zinit-autoload.zsh/.zinit-list-bindkeys
|   |-- zinit-autoload.zsh/.zinit-list-compdef-replay
Expand Down Expand Up @@ -229,7 +230,6 @@ Has 38 line(s). Calls functions:
Called by:
zinit
zinit-autoload.zsh/.zinit-delete
-zinit_scheduler_add_sh
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -749,7 +749,6 @@ Has 2 line(s). Doesn't call other functions.
Called by:
zinit
zinit-autoload.zsh/.zinit-delete
.zinit-prepare-home
~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -1104,7 +1103,6 @@ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
____
]]]
Registers the z-annex inside Zinit – i.e. an Zinit extension
____
Expand Down Expand Up @@ -1292,7 +1290,7 @@ ____
and completion.
____
Has 564 line(s). Calls functions:
Has 568 line(s). Calls functions:
zinit
|-- +zinit-message
Expand All @@ -1308,6 +1306,7 @@ Has 564 line(s). Calls functions:
|-- zinit-autoload.zsh/.zinit-clear-completions
|-- zinit-autoload.zsh/.zinit-compile-uncompile-all
|-- zinit-autoload.zsh/.zinit-compiled
|-- zinit-autoload.zsh/.zinit-delete
|-- zinit-autoload.zsh/.zinit-help
|-- zinit-autoload.zsh/.zinit-list-bindkeys
|-- zinit-autoload.zsh/.zinit-list-compdef-replay
Expand Down Expand Up @@ -1340,6 +1339,7 @@ Called by:
Script-Body
zplugin
zinit-autoload.zsh/.zinit-delete
zpcdclear
~~~~~~~~~
Expand Down Expand Up @@ -1398,6 +1398,7 @@ Has 1 line(s). Calls functions:
|-- zinit-autoload.zsh/.zinit-clear-completions
|-- zinit-autoload.zsh/.zinit-compile-uncompile-all
|-- zinit-autoload.zsh/.zinit-compiled
|-- zinit-autoload.zsh/.zinit-delete
|-- zinit-autoload.zsh/.zinit-help
|-- zinit-autoload.zsh/.zinit-list-bindkeys
|-- zinit-autoload.zsh/.zinit-list-compdef-replay
Expand Down Expand Up @@ -1461,7 +1462,7 @@ ____
Note that some terminals do not support all combinations.
____
Has 120 line(s). Doesn't call other functions.
Has 117 line(s). Doesn't call other functions.
Called by:
Expand All @@ -1484,7 +1485,7 @@ ____
`#compdef <names ...>'
____
Has 573 line(s). Doesn't call other functions.
Has 549 line(s). Doesn't call other functions.
Uses feature(s): _autoload_, _bindkey_, _compdef_, _compdump_, _eval_, _read_, _setopt_, _unfunction_, _zle_, _zstyle_
Expand Down
38 changes: 38 additions & 0 deletions tests/commands.zunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env zunit
#
# zdharma-continuum/zinit/tests/commands.zunit
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

@setup {
ZBIN="${ZPFX}/bin"
}
@test 'delete --help' {
run zinit delete --help
assert $output contains 'zinit delete [options] [plugins...]'
assert $state equals 0
}
@test 'delete --all' {
run zinit as'completion' is-snippet for @'https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker'
assert $state equals 0
}
@test 'delete a snippet' {
run zinit id-as'git.zsh' is-snippet for @'OMZL::git.zsh'
run zinit delete --yes 'git.zsh'
assert $state equals 0
}
@test 'delete a plugin' {
run zinit from'gh-r' as'program' id-as mv'shfmt* -> shfmt' for @'mvdan/sh'
run zinit delete --yes sh
assert $state equals 0
}
@test 'delete a program' {
run zinit as'program' cp'wd.sh->wd' mv'_wd.sh->_wd' pick'wd' for @'mfaerevaag/wd'
run zinit delete --yes mfaerevaag/wd
assert $state equals 0
}

# vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=marker
Loading

0 comments on commit 6a5d2b1

Please sign in to comment.