Allow filter to be empty for aptly * search commands

Empty filter implies "select all packages".
This commit is contained in:
Andrey Smirnov
2017-02-10 23:07:06 +03:00
parent 4eef4f1803
commit 33d6cd8c0a
15 changed files with 248901 additions and 23 deletions
+23
View File
@@ -72,6 +72,9 @@ type DependencyQuery struct {
Dep Dependency
}
// MatchAllQuery is query that matches all the packages
type MatchAllQuery struct{}
// Matches if any of L, R matches
func (q *OrQuery) Matches(pkg PackageLike) bool {
return q.L.Matches(pkg) || q.R.Matches(pkg)
@@ -275,3 +278,23 @@ func (q *PkgQuery) Query(list PackageCatalog) (result *PackageList) {
func (q *PkgQuery) String() string {
return fmt.Sprintf("%s_%s_%s", q.Pkg, q.Version, q.Arch)
}
// Matches on specific properties
func (q *MatchAllQuery) Matches(pkg PackageLike) bool {
return true
}
// Fast is always true for match all query
func (q *MatchAllQuery) Fast(list PackageCatalog) bool {
return true
}
// Query looks up specific package
func (q *MatchAllQuery) Query(list PackageCatalog) (result *PackageList) {
return list.Scan(q)
}
// String interface
func (q *MatchAllQuery) String() string {
return ""
}