support recursive inclusion
This commit is contained in:
parent
eb9152dbe4
commit
1dc2cd7e04
17
main.go
17
main.go
@ -119,7 +119,11 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
|||||||
Name: list.Name,
|
Name: list.Name,
|
||||||
Inclusion: make(map[string]bool),
|
Inclusion: make(map[string]bool),
|
||||||
}
|
}
|
||||||
for _, entry := range list.Entry {
|
entryList := list.Entry
|
||||||
|
for {
|
||||||
|
newEntryList := make([]Entry, 0, len(entryList))
|
||||||
|
hasInclude := false
|
||||||
|
for _, entry := range entryList {
|
||||||
if entry.Type == "include" {
|
if entry.Type == "include" {
|
||||||
if pl.Inclusion[entry.Value] {
|
if pl.Inclusion[entry.Value] {
|
||||||
continue
|
continue
|
||||||
@ -130,11 +134,18 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
|||||||
if r == nil {
|
if r == nil {
|
||||||
return nil, errors.New(entry.Value + " not found.")
|
return nil, errors.New(entry.Value + " not found.")
|
||||||
}
|
}
|
||||||
pl.Entry = append(pl.Entry, r.Entry...)
|
newEntryList = append(newEntryList, r.Entry...)
|
||||||
|
hasInclude = true
|
||||||
} else {
|
} else {
|
||||||
pl.Entry = append(pl.Entry, entry)
|
newEntryList = append(newEntryList, entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
entryList = newEntryList
|
||||||
|
if !hasInclude {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pl.Entry = entryList
|
||||||
|
|
||||||
return pl, nil
|
return pl, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user