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
|
package main
import (
"fmt"
"io/fs"
"os"
"website/internal/builder"
"website/internal/log"
"github.com/BurntSushi/toml"
"github.com/ardanlabs/conf/v3"
"github.com/pkg/errors"
)
func main() {
ioConfig := builder.IOConfig{}
if help, err := conf.Parse("", &ioConfig); err != nil {
if errors.Is(err, conf.ErrHelpWanted) {
fmt.Println(help)
os.Exit(1)
}
panic("error parsing configuration: " + err.Error())
}
log.Configure(!ioConfig.Development)
log.Debug("starting build process")
if ioConfig.Source != "." {
err := os.Chdir(ioConfig.Source)
if err != nil {
log.Panic("could not change to source directory")
}
}
r, err := builder.BuildSite(ioConfig)
if err != nil {
switch cause := errors.Cause(err).(type) {
case *fs.PathError:
log.Error("path error", "error", err)
case toml.ParseError:
log.Info("parse error", "error", err)
default:
log.Info("other error", "error", err, "cause", errors.Cause(cause))
}
os.Exit(1)
}
for _, h := range r.Hashes {
fmt.Printf("'%s'\n", h)
}
}
|