person: add a function to test the matching of a query

Michael Muré created

Change summary

bug/person.go | 6 ++++++
1 file changed, 6 insertions(+)

Detailed changes

bug/person.go 🔗

@@ -2,6 +2,7 @@ package bug
 
 import (
 	"errors"
+	"strings"
 
 	"github.com/MichaelMure/git-bug/repository"
 )
@@ -31,3 +32,8 @@ func GetUser(repo repository.Repo) (Person, error) {
 
 	return Person{Name: name, Email: email}, nil
 }
+
+// Match tell is the Person match the given query string
+func (p Person) Match(query string) bool {
+	return strings.Contains(strings.ToLower(p.Name), strings.ToLower(query))
+}