package main import ( "fmt" "os" "go.alanpearce.eu/website/internal/builder" "go.alanpearce.eu/website/internal/config" "go.alanpearce.eu/website/internal/vcs" "go.alanpearce.eu/x/log" "github.com/ardanlabs/conf/v3" "gitlab.com/tozd/go/errors" ) const branch = "main" 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) repo, _, err := vcs.CloneOrOpen(&vcs.Options{ LocalPath: builderOptions.Source, RemoteURL: builderOptions.VCSRemoteURL, Branch: branch, }, log.Named("vcs")) if err != nil { panic("could not open repository: " + err.Error()) } builderOptions.Repo = repo log.Debug("starting build process") cfg, err := config.GetConfig(builderOptions.Source, log) if err != nil { log.Error("could not read config", "error", err) } _, err = builder.BuildSite(builderOptions, cfg, log) if err != nil { log.Error("could not build site", "error", err) os.Exit(1) } }