r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
646 stars 57 forks source link

`pkg_search()` doesn't give the correct message when less match #505

Closed olivroy closed 1 year ago

olivroy commented 1 year ago

Hello,

This issue is very minor and possibly not very important.. When not many results are returned from pkg_search(), we still get hits 1-10 even if there are less than 10 hits.

pak::pkg_search("gist")
#> 
#> # 'gist' -- hits 1-10 of 4
#> 
#> 1 gistr 0.9.0 -- by Scott Chamberlain, 3 years ago
#>   Work with 'GitHub' 'Gists'
#> 
#> 2 switchrGist 0.2.5 -- by Gabriel Becker, about a year ago
#>   Publish Package Manifests to GitHub Gists
#> 
#> 3 mapr 0.5.2 -- by Scott Chamberlain, 3 years ago
#>   Visualize Species Occurrence Data
#> 
#> 4 revengc 1.0.4 -- by Samantha Duchscherer, 4 years ago
#>   Reverse Engineering Summarized Data

Created on 2023-06-13 with reprex v2.0.2

Possibly, these lines could be changed.

https://github.com/r-lib/pak/blob/75586c1e95a73fa8628767bcba372b4c16d82ae6/R/search.R#L56 https://github.com/r-lib/pak/blob/75586c1e95a73fa8628767bcba372b4c16d82ae6/R/search.R#L57

Maybe something like:

#> # 'gist' -- 4 hits

instead.

It is fine when there are more results though and definitely not a priority

pak::pkg_search("git")
#> 
#> # 'git' -- hits 1-10 of 52
#> 
#> 1 gert 1.9.2 -- by Jeroen Ooms, 6 months ago
#>   Simple Git Client for R
#> 
#> 2 gitr 0.0.1 -- by Stu Field, 4 months ago
#>   A Lightweight API for 'Git'
#> 
#> 3 git4r 0.1.2 -- by John Hobbs, about a year ago
#>   Interactive Git for R
#> 
#> 4 git2r 0.32.0 -- by Stefan Widgren, 2 months ago
#>   Provides Access to Git Repositories
#> 
#> 5 credentials 1.3.2 -- by Jeroen Ooms, 2 years ago
#>   Tools for Managing SSH and Git Credentials
#> 
#> 6 bisectr 0.1.0 -- by Winston Chang, 11 years ago
#>   Tools to find bad commits with git bisect
#> 
#> 7 gitcreds 0.1.2 -- by Gábor Csárdi, 9 months ago
#>   Query 'git' Credentials from 'R'
#> 
#> 8 git2rdata 0.4.0 -- by Thierry Onkelinx, about a year ago
#>   Store and Retrieve Data.frames in a Git Repository
#> 
#> 9 askpass 1.1 -- by Jeroen Ooms, 4 years ago
#>   Safe Password Entry for R, Git, and SSH
#> 
#> 10 gitlink 0.1.3 -- by Cole Arendt, 4 years ago
#>   Add 'Git' Links to Your Web Based Assets

Created on 2023-06-13 with reprex v2.0.2

gaborcsardi commented 1 year ago

Thanks, makes sense. Would you like to submit a PR? (No pressure at all. :)) Potentially this needs to be fixed in the r-hub/pkgsearch package.

olivroy commented 1 year ago

I don't mind taking a look. However, there are no tests in pak for pkg_search() .

How would you create them? I could try to fix my use case, but I don't know exactly what it is supposed to do in all other cases

Thanks

olivroy commented 1 year ago

Turns out it was pretty simple (if we don't mind overriding the metadata) for the print method (only present in pak, not in pkgsearch)