Skip to content

Commit

Permalink
feat: delete subcommand refactor
Browse files Browse the repository at this point in the history
- `delete` subcommand can now take multiple arguments
- improved logic for `--all`, `--clean` flags
- improved log output
- now cleans up broken symlinks

```
zinit delete <Plugin> <Plugin> ...
```

Closes #57
Closes #239

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
  • Loading branch information
vladdoster committed Apr 2, 2023
1 parent 0bdf9ea commit 9eee215
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 193 deletions.
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
51 changes: 34 additions & 17 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 Expand Up @@ -1428,7 +1447,5 @@ Has 2 line(s). Calls functions:
zi::version
`-- zinit.zsh/+zinit-message
Called by:
zinit.zsh/zinit
Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
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 9eee215

Please sign in to comment.