1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package main
import (
"fmt"
"os"
"go.alanpearce.eu/website/internal/builder"
"go.alanpearce.eu/website/internal/config"
"go.alanpearce.eu/website/internal/storage/sqlite"
"go.alanpearce.eu/x/log"
"github.com/ardanlabs/conf/v3"
"gitlab.com/tozd/go/errors"
)
func main() {
builderOptions := &builder.Options{}
if help, err := conf.Parse("", builderOptions); err != nil {
if errors.Is(err, conf.ErrHelpWanted) {
fmt.Println(help)
os.Exit(1)
}
panic("error parsing configuration: " + err.Error())
}
log := log.Configure(!builderOptions.Development)
log.Debug("starting build process")
if builderOptions.Source != "." {
err := os.Chdir(builderOptions.Source)
if err != nil {
log.Panic("could not change to source directory")
}
}
cfg, err := config.GetConfig(builderOptions.Source, log)
if err != nil {
log.Error("could not read config", "error", err)
}
db, err := sqlite.OpenDB(builderOptions.DBPath)
if err != nil {
log.Error("could not open database", "error", err)
return
}
builderOptions.DB = db
_, err = builder.BuildSite(builderOptions, cfg, log)
if err != nil {
log.Error("could not build site", "error", err)
os.Exit(1)
}
}
|