1
0
mirror of https://git.sr.ht/~adnano/kiln synced 2024-11-08 14:19:20 +01:00

Add -format flag

This commit is contained in:
adnano 2021-02-27 15:34:05 -05:00
parent 6e8f7cfdaa
commit f1d0710f95

22
main.go

@ -17,11 +17,20 @@ func main() {
}
func run() error {
// whether or not to output HTML
var toHTML bool
flag.BoolVar(&toHTML, "html", false, "output HTML")
var format string
flag.StringVar(&format, "format", "gemini", "output format to use. Supported formats include gemini and html")
flag.Parse()
var output outputFormat
switch format {
case "gemini":
output = outputGemini
case "html":
output = outputHTML
default:
log.Fatalf("unknown output format %q", format)
}
// Load config
cfg := NewConfig()
if err := cfg.Load("config.ini"); err != nil {
@ -42,14 +51,9 @@ func run() error {
return err
}
// Write content
if err := dir.write("dst", outputGemini, cfg); err != nil {
if err := dir.write("dst", output, cfg); err != nil {
return err
}
if toHTML {
if err := dir.write("html", outputHTML, cfg); err != nil {
return err
}
}
return nil
}