refactor: improve `fisher rm` completions

For tab completions we want to list only the packages that you
added yourself (via the CLI or fishfile) and ignore those that
are installed but are dependencies of another package/s.
pull/516/head
Jorge Bucaran 5 years ago
parent 5cb9b3d7ea
commit fbfc7c04f3
No known key found for this signature in database
GPG Key ID: E54BA3C0E646DB30

@ -79,12 +79,15 @@ function _fisher_self_complete
complete -ec fisher
complete -xc fisher -n __fish_use_subcommand -a add -d "Add packages"
complete -xc fisher -n __fish_use_subcommand -a rm -d "Remove packages"
complete -xc fisher -n __fish_use_subcommand -a ls -d "List added packages"
complete -xc fisher -n __fish_use_subcommand -a ls -d "List installed packages"
complete -xc fisher -n __fish_use_subcommand -a help -d "Show usage help"
complete -xc fisher -n __fish_use_subcommand -a version -d "$fisher_version"
complete -xc fisher -n __fish_use_subcommand -a self-update -d "Update to the latest version"
set -l file (_fisher_fmt < $fisher_path/fishfile | _fisher_read)
for pkg in (_fisher_ls | _fisher_fmt)
complete -xc fisher -n "__fish_seen_subcommand_from rm" -a $pkg
if contains -- $pkg $file
complete -xc fisher -n "__fish_seen_subcommand_from rm" -a $pkg
end
end
end
@ -260,7 +263,7 @@ function _fisher_read -a cmd
if (CMD == "rm") {
for (pkg in pkgs) {
if (!(pkg in file)) {
print "cannot remove \"" pkg "\" -- package not found" > "/dev/stderr"
print "cannot remove \""pkg"\" -- package not listed in fishfile" > "/dev/stderr"
}
}
}

Loading…
Cancel
Save