yay/pkg/query/filter.go

31 lines
771 B
Go
Raw Normal View History

package query
2020-07-10 00:36:45 +00:00
import (
"github.com/leonelquinteros/gotext"
"github.com/Jguer/yay/v12/pkg/settings/parser"
"github.com/Jguer/yay/v12/pkg/text"
2020-07-10 00:36:45 +00:00
)
func RemoveInvalidTargets(targets []string, mode parser.TargetMode) []string {
2020-07-10 00:36:45 +00:00
filteredTargets := make([]string, 0)
for _, target := range targets {
2020-08-01 07:55:08 +00:00
dbName, _ := text.SplitDBFromName(target)
2020-07-10 00:36:45 +00:00
2021-08-09 11:26:32 +00:00
if dbName == "aur" && !mode.AtLeastAUR() {
2020-07-10 00:36:45 +00:00
text.Warnln(gotext.Get("%s: can't use target with option --repo -- skipping", text.Cyan(target)))
continue
}
2021-08-09 11:26:32 +00:00
if dbName != "aur" && dbName != "" && !mode.AtLeastRepo() {
2020-07-10 00:36:45 +00:00
text.Warnln(gotext.Get("%s: can't use target with option --aur -- skipping", text.Cyan(target)))
continue
}
filteredTargets = append(filteredTargets, target)
}
return filteredTargets
}