Add an option to increase verbosity (e.g. to mark installed packages)

This commit is contained in:
Les De Ridder 2019-03-24 09:26:15 +01:00
parent decae1b9a8
commit 0c7f1d7e8d
1 changed files with 30 additions and 2 deletions

32
saury
View File

@ -51,7 +51,8 @@ function print_usage
print_operation "{-V --version}"
print_operation "{-A --aur-sync} [options] [package(s)]"
echo 'options:'
echo ' --color <auto/always/never>'
echo ' -c, --color=<auto/always/never>'
echo ' -v, --verbose'
end
function print_version
@ -82,6 +83,13 @@ function aur_search
map(.Name, .PackageBase, .Description, .Version,
.OutOfDate != null, .NumVotes, (.Popularity * 100 | round / 100))[]')
if test $_flag_verbose
begin
set -l IFS
set installed_packages (pacman -Q)
end
end
for i in (seq (math (count $results) / 7))
set name $results[(math $i \* 7 - 6)]
set package_base $results[(math $i \* 7 - 5)]
@ -117,6 +125,22 @@ function aur_search
(set_color CC6733) "$popularity" \
(set_color normal; set_color --bold) ')')
if test $_flag_verbose
# not shown by default because it's quite slow
set installed (echo $installed_packages | grep -E "^$name ")
if test "$installed"
echo -n ' [installed'
set installed_version (echo $installed | cut -d' ' -f2)
if test "$package_version" != "$installed_version"
echo -n ": $installed_version"
end
echo -n ']'
end
end
echo
set_color normal
@ -165,7 +189,7 @@ function main
set aur_sync_exclusive_options 's,u'
argparse -n $saury_name -x 'V,A' -x $aur_sync_exclusive_options \
'h/help' 'V/version' 'A/aur-sync' 'c-color=?' $aur_sync_options -- $argv \
'h/help' 'V/version' 'A/aur-sync' 'c/color=?' 'v/verbose' $aur_sync_options -- $argv \
^| sed (string join '' 's/:/:' (set_color red) '/;s/$/' (set_color normal) '/') | head -1
if not set --local --query argv
@ -182,6 +206,10 @@ function main
end
end
if test $_flag_verbose
set -g _flag_verbose $_flag_verbose
end
if set --query _flag_help
print_usage
else if set --query _flag_version