mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 09:37:22 +01:00
d13bdb0ce1
* unify query builder * remove uneeded code * reorganize code
44 lines
702 B
Go
44 lines
702 B
Go
package query
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/Jguer/aur"
|
|
"github.com/hashicorp/go-multierror"
|
|
)
|
|
|
|
type SearchVerbosity int
|
|
|
|
// Verbosity settings for search.
|
|
const (
|
|
NumberMenu SearchVerbosity = iota
|
|
Detailed
|
|
Minimal
|
|
)
|
|
|
|
// queryAUR searches AUR and narrows based on subarguments.
|
|
func queryAUR(ctx context.Context,
|
|
aurClient aur.QueryClient,
|
|
pkgS []string, searchBy string,
|
|
) ([]aur.Pkg, error) {
|
|
var (
|
|
err error
|
|
by = getSearchBy(searchBy)
|
|
)
|
|
|
|
for _, word := range pkgS {
|
|
r, errM := aurClient.Get(ctx, &aur.Query{
|
|
Needles: []string{word},
|
|
By: by,
|
|
Contains: true,
|
|
})
|
|
if errM == nil {
|
|
return r, nil
|
|
}
|
|
|
|
err = multierror.Append(err, errM)
|
|
}
|
|
|
|
return nil, err
|
|
}
|