Add an option to show less information for search
This commit is contained in:
parent
86d1942d74
commit
51a9cbf08e
153
saury
153
saury
|
@ -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,83 +79,93 @@ function aur_search
|
|||
set rpc_response_type (echo $rpc_response | jq -r '.type')
|
||||
|
||||
if test "$rpc_response_type" = "search"
|
||||
set results (echo $rpc_response | \
|
||||
jq -r '.results | sort_by(.NumVotes, (.Name | explode | map(-.))) | reverse |
|
||||
map(.Name, .PackageBase, .Description, .Version,
|
||||
.OutOfDate != null, .NumVotes, (.Popularity * 100 | round / 100))[]')
|
||||
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,
|
||||
.OutOfDate != null, .NumVotes, (.Popularity * 100 | round / 100))[]')
|
||||
|
||||
if test $_flag_verbose
|
||||
begin
|
||||
set -l IFS
|
||||
set installed_packages (pacman -Q)
|
||||
end
|
||||
end
|
||||
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)]
|
||||
set description $results[(math $i \* 7 - 4)]
|
||||
set package_version $results[(math $i \* 7 - 3)]
|
||||
set out_of_date $results[(math $i \* 7 - 2)]
|
||||
set votes $results[(math $i \* 7 - 1)]
|
||||
set popularity $results[(math $i \* 7)]
|
||||
for i in (seq (math (count $results) / 7))
|
||||
set name $results[(math $i \* 7 - 6)]
|
||||
set package_base $results[(math $i \* 7 - 5)]
|
||||
set description $results[(math $i \* 7 - 4)]
|
||||
set package_version $results[(math $i \* 7 - 3)]
|
||||
set out_of_date $results[(math $i \* 7 - 2)]
|
||||
set votes $results[(math $i \* 7 - 1)]
|
||||
set popularity $results[(math $i \* 7)]
|
||||
|
||||
set_color --bold
|
||||
echo -n (string join -- "" \
|
||||
(set_color CC3399) "aur/" \
|
||||
(set_color normal; set_color --bold) (string replace -a -i -- \
|
||||
set_color --bold
|
||||
echo -n (string join -- "" \
|
||||
(set_color CC3399) "aur/" \
|
||||
(set_color normal; set_color --bold) (string replace -a -i -- \
|
||||
"$query" \
|
||||
(string join -- "" (set_color 33CCB3) \
|
||||
"$query" \
|
||||
(set_color normal; set_color --bold)) \
|
||||
"$name"))
|
||||
echo -n ' '
|
||||
|
||||
if test $out_of_date = "true"
|
||||
set_color CC334D
|
||||
else
|
||||
set_color 33CC66
|
||||
end
|
||||
echo -n $package_version
|
||||
|
||||
if test "$name" != "$package_base"
|
||||
set_color 3399CC
|
||||
|
||||
echo -n " ($package_base)"
|
||||
end
|
||||
|
||||
echo -n (string join -- "" \
|
||||
(set_color normal; set_color --bold) ' (' \
|
||||
(set_color CC6733) "+$votes" \
|
||||
(set_color normal; set_color --bold) ' | ' \
|
||||
(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
|
||||
echo (string replace -a -i -- \
|
||||
"$query" \
|
||||
(string join -- "" (set_color 33CCB3) \
|
||||
"$query" \
|
||||
(set_color normal; set_color --bold)) \
|
||||
"$name"))
|
||||
echo -n ' '
|
||||
|
||||
if test $out_of_date = "true"
|
||||
set_color CC334D
|
||||
else
|
||||
set_color 33CC66
|
||||
(set_color normal)) \
|
||||
" $description")
|
||||
end
|
||||
echo -n $package_version
|
||||
else
|
||||
set results (echo $rpc_response | \
|
||||
jq -r '.results | sort_by(.NumVotes, (.Name | explode | map(-.))) | reverse |
|
||||
map(.Name)[]')
|
||||
|
||||
if test "$name" != "$package_base"
|
||||
set_color 3399CC
|
||||
|
||||
echo -n " ($package_base)"
|
||||
for package in $results
|
||||
echo $package
|
||||
end
|
||||
|
||||
echo -n (string join -- "" \
|
||||
(set_color normal; set_color --bold) ' (' \
|
||||
(set_color CC6733) "+$votes" \
|
||||
(set_color normal; set_color --bold) ' | ' \
|
||||
(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
|
||||
echo (string replace -a -i -- \
|
||||
"$query" \
|
||||
(string join -- "" (set_color 33CCB3) \
|
||||
"$query" \
|
||||
(set_color normal)) \
|
||||
" $description")
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue