feat(cli): main arguments

This commit is contained in:
Anhgelus Morhtuuzh 2024-11-09 21:33:11 +01:00
parent b637ff02f6
commit a50d678a67
No known key found for this signature in database
GPG key ID: CAD341EFA92DDDE5

25
main.go
View file

@ -2,20 +2,41 @@ package main
import ( import (
"embed" "embed"
"flag"
"github.com/anhgelus/golatt" "github.com/anhgelus/golatt"
"log/slog"
) )
//go:embed templates //go:embed templates
var templates embed.FS var templates embed.FS
var (
domain string
data string
)
func init() {
flag.StringVar(&domain, "domain", "", "domain to use")
flag.StringVar(&data, "data", "", "data to use")
}
func main() { func main() {
flag.Parse()
if domain == "" {
slog.Error("Domain not set. Set it with --domain value")
return
}
if data == "" {
slog.Error("Data not set. Set it with --data relative path")
return
}
g := golatt.New(templates) g := golatt.New(templates)
g.DefaultSeoData = &golatt.SeoData{ g.DefaultSeoData = &golatt.SeoData{
Image: "", Image: "",
Description: "", Description: "",
Domain: "now.anhgelus.world", Domain: domain,
} }
g.Templates = append(g.Templates, "templates/page/*.gohtml") g.Templates = append(g.Templates, "templates/page/*.gohtml")
g.StartServer(":80") //g.StartServer(":80")
} }