diff --git a/structure/emitter.go b/structure/emitter.go new file mode 100644 index 0000000..d553b86 --- /dev/null +++ b/structure/emitter.go @@ -0,0 +1,24 @@ +package structure + +import ( + "os" + "path/filepath" + "tangled.org/cosmeak.tngl.sh/weave/internal/generator" +) + +// The idea here is just to get the data from the file, the filename +// and then move all this information to the datapack. Nothing fancy +// or complicated here. +func (s Structure) Emit() (generator.File, error) { + path := "data/%namespace%/structure/" + filepath.Base(s.filePath) + + content, err := os.ReadFile(s.filePath) + if err != nil { + return generator.File{}, err + } + + return generator.File{ + Path: path, + Content: content, + }, nil +} diff --git a/structure/structure.go b/structure/structure.go new file mode 100644 index 0000000..66f3e98 --- /dev/null +++ b/structure/structure.go @@ -0,0 +1,19 @@ +package structure + +type Structure struct { + filePath string +} + +func MkStructure(name, filePath string) Structure { + return Structure{ + filePath: filePath, + } +} + +func (s Structure) Type() string { + return "structure" +} + +func (s Structure) FilePath() string { + return s.filePath +}