mermaid-server/cmd/app/main.go

47 lines
1.1 KiB
Go
Raw Normal View History

package main
import (
"context"
"flag"
"fmt"
2021-08-14 17:34:07 +02:00
"github.com/tomwright/grace"
2020-04-15 17:59:58 +02:00
"github.com/tomwright/mermaid-server/internal"
"os"
)
func main() {
mermaid := flag.String("mermaid", "", "The full path to the mermaidcli executable.")
in := flag.String("in", "", "Directory to store input files.")
out := flag.String("out", "", "Directory to store output files.")
puppeteer := flag.String("puppeteer", "", "Full path to optional puppeteer config.")
flag.Parse()
if *mermaid == "" {
_, _ = fmt.Fprintf(os.Stderr, "Missing required argument `mermaid`")
os.Exit(1)
}
if *in == "" {
_, _ = fmt.Fprintf(os.Stderr, "Missing required argument `in`")
os.Exit(1)
}
if *out == "" {
_, _ = fmt.Fprintf(os.Stderr, "Missing required argument `out`")
os.Exit(1)
}
2021-08-14 17:34:07 +02:00
g := grace.Init(context.Background())
cache := internal.NewDiagramCache()
generator := internal.NewGenerator(cache, *mermaid, *in, *out, *puppeteer)
2021-08-14 17:34:07 +02:00
httpRunner := internal.NewHTTPRunner(generator)
cleanupRunner := internal.NewCleanupRunner(generator)
2021-08-14 17:34:07 +02:00
g.Run(httpRunner)
g.Run(cleanupRunner)
2021-08-14 17:34:07 +02:00
g.Wait()
}