__fish_print_packages: Extract the rest

Of note: The rpm/yum thing seems to be coupled, so I put it into one
function that tries the yum helper and uses the rpm path otherwise.
Zypper is already its own thing, so this should only be used for yum
and probably dnf (does that still have the helper?)

Zypper can be dropped, as that already used a separate function in the file.

Apk can just be inlined - it's literally one line for installed and another for all packages.
This commit is contained in:
Fabian Homborg
2020-09-22 19:24:04 +02:00
parent cf59c3b680
commit 04d7d89020
42 changed files with 235 additions and 264 deletions

View File

@@ -2,18 +2,13 @@ function __fish_print_apt_packages
argparse --name=__fish_print_packages i/installed -- $argv
or return
set -l only_installed 1
if not set -q _flag_installed
set -e only_installed
end
switch (commandline -ct)
case '-**'
return
end
type -q -f apt-cache || return 1
if not set -q only_installed
if not set -q _flag_installed
# Do not generate the cache as apparently sometimes this is slow.
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=547550
# (It is safe to use `sed -r` here as we are guaranteed to be on a GNU platform