Interface for treating several files as one file
Some applications treat an entire directory as a configuration, merging the configurations from all of the files in a directory and treating them as one. MergeFiles supports this idea by wrapping the bodies of the several files. It's not yet implemented here, but once implemented it will act as an aggregator of the content of the wrapped bodies, delegating to them for actual body content and then merging the returned body content in a well-defined way.
This commit is contained in:
parent
41527d1a3c
commit
1ecde9204c
35
zcl/merged.go
Normal file
35
zcl/merged.go
Normal file
@ -0,0 +1,35 @@
|
||||
package zcl
|
||||
|
||||
// MergeFiles combines the given files to produce a single body that contains
|
||||
// configuration from all of the given files.
|
||||
//
|
||||
// The ordering of the given files decides the order in which contained
|
||||
// elements will be returned. If any top-level attributes are defined with
|
||||
// the same name across multiple files, a diagnostic will be produced from
|
||||
// the Content and PartialContent methods describing this error in a
|
||||
// user-friendly way.
|
||||
func MergeFiles(files []*File) Body {
|
||||
var bodies []Body
|
||||
for _, file := range files {
|
||||
bodies = append(bodies, file.Body)
|
||||
}
|
||||
return MergeBodies(bodies)
|
||||
}
|
||||
|
||||
// MergeBodies is like MergeFiles except it deals directly with bodies, rather
|
||||
// than with entire files.
|
||||
func MergeBodies(bodies []Body) Body {
|
||||
return mergedBodies(bodies)
|
||||
}
|
||||
|
||||
type mergedBodies []Body
|
||||
|
||||
func (mb mergedBodies) Content(schema *BodySchema) (*BodyContent, Diagnostics) {
|
||||
// TODO: Implement
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (mb mergedBodies) PartialContent(schema *BodySchema) (*BodyContent, Body, Diagnostics) {
|
||||
// TODO: Implement
|
||||
return nil, nil, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user