2020-09-22 20:42:14 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2020-09-28 23:54:48 +00:00
|
|
|
)
|
|
|
|
|
2020-09-22 20:42:14 +00:00
|
|
|
func main() {
|
2020-10-01 01:57:59 +00:00
|
|
|
if err := run(); err != nil {
|
2020-09-22 20:42:14 +00:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-20 17:07:38 +00:00
|
|
|
func run() error {
|
|
|
|
// Load config
|
2021-03-20 06:02:36 +00:00
|
|
|
cfg, err := LoadConfig("config.toml")
|
|
|
|
if err != nil {
|
2020-11-20 17:07:38 +00:00
|
|
|
return err
|
|
|
|
}
|
2021-03-20 06:18:15 +00:00
|
|
|
if err := cfg.LoadTemplates("templates"); err != nil {
|
2020-11-20 17:07:38 +00:00
|
|
|
return err
|
2020-10-01 02:14:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 03:17:58 +00:00
|
|
|
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
|
|
|
|
}
|
2021-02-28 02:53:16 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 20:42:14 +00:00
|
|
|
return nil
|
|
|
|
}
|