Add -format flag

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

22
main.go
View file

@ -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
}