mirror of
https://github.com/Jguer/yay.git
synced 2025-10-04 00:03:11 -04:00
Merge pull request #315 from Morganamilo/fix#314
Try each search term against RPC if one fails
This commit is contained in:
commit
13ba261977
2
cmd.go
2
cmd.go
@ -362,7 +362,7 @@ func handleRemove() (err error) {
|
|||||||
func numberMenu(pkgS []string, flags []string) (err error) {
|
func numberMenu(pkgS []string, flags []string) (err error) {
|
||||||
aurQ, err := narrowSearch(pkgS, true)
|
aurQ, err := narrowSearch(pkgS, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error during AUR search:", err)
|
return fmt.Errorf("Error during AUR search: %s", err)
|
||||||
}
|
}
|
||||||
numaq := len(aurQ)
|
numaq := len(aurQ)
|
||||||
repoQ, numpq, err := queryRepo(pkgS)
|
repoQ, numpq, err := queryRepo(pkgS)
|
||||||
|
19
query.go
19
query.go
@ -72,11 +72,22 @@ func filterPackages() (local []alpm.Package, remote []alpm.Package,
|
|||||||
|
|
||||||
// NarrowSearch searches AUR and narrows based on subarguments
|
// NarrowSearch searches AUR and narrows based on subarguments
|
||||||
func narrowSearch(pkgS []string, sortS bool) (aurQuery, error) {
|
func narrowSearch(pkgS []string, sortS bool) (aurQuery, error) {
|
||||||
|
var r []rpc.Pkg
|
||||||
|
var err error
|
||||||
|
var usedIndex int
|
||||||
|
|
||||||
if len(pkgS) == 0 {
|
if len(pkgS) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := rpc.Search(pkgS[0])
|
for i, word := range pkgS {
|
||||||
|
r, err = rpc.Search(word)
|
||||||
|
if err == nil {
|
||||||
|
usedIndex = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -93,7 +104,11 @@ func narrowSearch(pkgS []string, sortS bool) (aurQuery, error) {
|
|||||||
|
|
||||||
for _, res := range r {
|
for _, res := range r {
|
||||||
match := true
|
match := true
|
||||||
for _, pkgN := range pkgS[1:] {
|
for i, pkgN := range pkgS {
|
||||||
|
if usedIndex == i {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if !(strings.Contains(res.Name, pkgN) || strings.Contains(strings.ToLower(res.Description), pkgN)) {
|
if !(strings.Contains(res.Name, pkgN) || strings.Contains(strings.ToLower(res.Description), pkgN)) {
|
||||||
match = false
|
match = false
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user