1
0
mirror of https://git.sr.ht/~adnano/kiln synced 2024-11-08 10:09:18 +01:00
kiln/main.go

45 lines
729 B
Go

package main
import (
"log"
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
// Load config
cfg, err := LoadConfig("config.toml")
if err != nil {
return err
}
if err := cfg.LoadTemplates("templates"); err != nil {
return err
}
for _, task := range cfg.Tasks {
// Load content
dir := NewDir("")
dir.inputExt = task.Input
dir.outputExt = task.Output
dir.templateExt = task.Template
if err := dir.read("content", ""); err != nil {
return err
}
dir.sort()
// Manipulate content
if err := dir.manipulate(cfg); err != nil {
return err
}
// Write content
if err := dir.write(task.Destination, task); err != nil {
return err
}
}
return nil
}