trizen / trizen

Lightweight AUR Package Manager
https://github.com/trizen/trizen/blob/master/TRIZEN.md
GNU General Public License v3.0
794 stars 40 forks source link

Display a message when aur responds with too many results #154

Closed warptozero closed 6 years ago

warptozero commented 6 years ago

When submitting a search to the aur that yields a lot of results (for example trizen -Sas python), the aur responds with code 200 OK and the following json data:

{
  "version": 5,
  "type": "error",
  "resultcount": 0,
  "results": [],
  "error": "Too many package results."
}

However trizen displays nothing implying that the search yielded no results. It would be helpfull if trizen responded with an aur-says-no message.

trizen commented 6 years ago

This looks like a straightforward error message to add, but it's not, because when we search for multiple keywords, one of which is python, we don't want to display this error message.

For example:

$ trizen -Ssa python pillow
aur/python-pillow-git 1.7.6.r1267.gbed2e42-1 [2+] [0.01%] [10 Jun 2015]
    Python Imaging Library (PIL) fork. (git, Python 3)
aur/python-pillow-simd 5.0.0-1 [2+] [0.25%] [11 Feb 2018]
    Python Imaging Library (PIL) fork. Pillow fork for better image processing performance.
aur/python-pypillowfight 0.2.4-1 [5+] [0.01%] [12 Apr 2018]
    Library containing various image processing algorithms
aur/python-pyscreenshot 0.4.2-2 [1+] [0.03%] [29 Oct 2017]
    Copy the contents of the screen to a PIL or Pillow image memory

It does fail to search for python, but it succeeds in searching for pillow. After that, the results are narrowed down to match both python and pillow.

So I don't think it's worth the effort to complicate the code just to add something useless, like displaying an error message.

warptozero commented 6 years ago

I don't think it's useless to tell the user what went wrong in the service that's being wrapped.

As of now trizen doesn't check the return type of the request, wouldn't that be a good thing to do anyway? I assume the AUR can throw other kinds of errors too, without displaying those the user has no idea what to blame (bad search, trizen, AUR), or that there even is a problem (no results).

As of multiple keywords, just display a single message:

$ trizen -Ssa python pillow
:: AUR (python): Too many package results.
aur/python-pillow-git 1.7.6.r1267.gbed2e42-1 [2+] [0.01%] [10 Jun 2015]
    Python Imaging Library (PIL) fork. (git, Python 3)
...

The complication would be an error check after every json2perl call, which occurs in 4 places.