Add an option to show less information for search

This commit is contained in:
Les De Ridder 2019-03-26 03:59:25 +01:00
parent 86d1942d74
commit 51a9cbf08e
1 changed files with 84 additions and 69 deletions

17
saury
View File

@ -53,6 +53,7 @@ function print_usage
echo 'options:'
echo ' -c, --color=<auto/always/never>'
echo ' -v, --verbose'
echo ' -q, --quiet'
end
function print_version
@ -78,6 +79,7 @@ function aur_search
set rpc_response_type (echo $rpc_response | jq -r '.type')
if test "$rpc_response_type" = "search"
if not test $_flag_quiet
set results (echo $rpc_response | \
jq -r '.results | sort_by(.NumVotes, (.Name | explode | map(-.))) | reverse |
map(.Name, .PackageBase, .Description, .Version,
@ -156,6 +158,15 @@ function aur_search
(set_color normal)) \
" $description")
end
else
set results (echo $rpc_response | \
jq -r '.results | sort_by(.NumVotes, (.Name | explode | map(-.))) | reverse |
map(.Name)[]')
for package in $results
echo $package
end
end
else if test "$rpc_response_type" = "error"
set rpc_error (echo $rpc_response | jq -r '.error')
@ -199,7 +210,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=?' 'v/verbose' $aur_sync_options -- $argv \
'h/help' 'V/version' 'A/aur-sync' 'c/color=?' 'v/verbose' 'q/quiet' $aur_sync_options -- $argv \
^| sed (string join '' 's/:/:' (set_color red) '/;s/$/' (set_color normal) '/') | head -1
if not set --local --query argv
@ -220,6 +231,10 @@ function main
set -g _flag_verbose $_flag_verbose
end
if test $_flag_quiet
set -g _flag_quiet $_flag_quiet
end
if set --query _flag_help
print_usage
else if set --query _flag_version