diff --git a/tree.go b/tree.go index acb139d..85faf32 100644 --- a/tree.go +++ b/tree.go @@ -60,24 +60,26 @@ func (t Tree) Slice(path string) (Tree, error) { return Tree{}, errors.New("tree was not found") } -func (t Tree) Filter(filter map[string]string) (Tree, bool) { +func (t Tree) Filter(filter map[string][]string) (Tree, bool) { filtered := Tree{} filtered.Path = t.Path found := false for _, f := range t.Files { addFile := false - for option, value := range filter { - if option == "tag" { - for _, tag := range f.Tags { - if tag == value { - addFile = true + for option, values := range filter { + for _, value := range values { + if option == "tag" { + for _, tag := range f.Tags { + if tag == value { + addFile = true + } } + continue + } + if strings.Contains(f.Meta[option], value) { + addFile = true } - continue - } - if strings.Contains(f.Meta[option], value) { - addFile = true } } if addFile {