aboutsummaryrefslogtreecommitdiffstats
path: root/cache/filter.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-10 12:47:05 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-10 12:47:05 +0200
commitc8239a990b9babe071f08b78ad0195f01550d628 (patch)
treecce35c80f584a66fde4b659b5be15857e1b2e6d4 /cache/filter.go
parentece9e39461bb40df979c22092873eff014fc1648 (diff)
downloadgit-bug-c8239a990b9babe071f08b78ad0195f01550d628.tar.gz
cache: doc & cleaning
Diffstat (limited to 'cache/filter.go')
-rw-r--r--cache/filter.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/cache/filter.go b/cache/filter.go
index 91ab20c0..3bcfe13e 100644
--- a/cache/filter.go
+++ b/cache/filter.go
@@ -6,8 +6,10 @@ import (
"github.com/MichaelMure/git-bug/bug"
)
+// Filter is a functor that match a subset of bugs
type Filter func(excerpt *BugExcerpt) bool
+// StatusFilter return a Filter that match a bug status
func StatusFilter(query string) (Filter, error) {
status, err := bug.StatusFromString(query)
if err != nil {
@@ -19,6 +21,7 @@ func StatusFilter(query string) (Filter, error) {
}, nil
}
+// AuthorFilter return a Filter that match a bug author
func AuthorFilter(query string) Filter {
cleaned := strings.TrimFunc(query, func(r rune) bool {
return r == '"' || r == '\''
@@ -29,6 +32,7 @@ func AuthorFilter(query string) Filter {
}
}
+// LabelFilter return a Filter that match a label
func LabelFilter(label string) Filter {
return func(excerpt *BugExcerpt) bool {
for _, l := range excerpt.Labels {
@@ -40,12 +44,14 @@ func LabelFilter(label string) Filter {
}
}
+// NoLabelFilter return a Filter that match the absence of labels
func NoLabelFilter() Filter {
return func(excerpt *BugExcerpt) bool {
return len(excerpt.Labels) == 0
}
}
+// Filters is a collection of Filter that implement a complex filter
type Filters struct {
Status []Filter
Author []Filter