support filter by many same options
This commit is contained in:
parent
7ed3c128f4
commit
6bc45afab5
1 changed files with 12 additions and 10 deletions
6
tree.go
6
tree.go
|
@ -60,14 +60,15 @@ 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 {
|
||||
for option, values := range filter {
|
||||
for _, value := range values {
|
||||
if option == "tag" {
|
||||
for _, tag := range f.Tags {
|
||||
if tag == value {
|
||||
|
@ -80,6 +81,7 @@ func (t Tree) Filter(filter map[string]string) (Tree, bool) {
|
|||
addFile = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if addFile {
|
||||
found = true
|
||||
filtered.Files = append(filtered.Files, f)
|
||||
|
|
Loading…
Reference in a new issue