mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
Add -format flag
This commit is contained in:
parent
6e8f7cfdaa
commit
f1d0710f95
22
main.go
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue