From f1d0710f9509c3e3973194e782b5b9da366325fd Mon Sep 17 00:00:00 2001 From: adnano Date: Sat, 27 Feb 2021 15:34:05 -0500 Subject: [PATCH] Add -format flag --- main.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 279af67..116eddb 100644 --- a/main.go +++ b/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 }