main.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package main
  2. import (
  3. "os"
  4. "path/filepath"
  5. "github.com/cdelorme/glog"
  6. "github.com/cdelorme/gonf"
  7. "github.com/cdelorme/static"
  8. "github.com/russross/blackfriday"
  9. )
  10. var exit = os.Exit
  11. var getwd = os.Getwd
  12. var operate = blackfriday.MarkdownCommon
  13. func main() {
  14. cwd, _ := getwd()
  15. smd := &static.Markdown{
  16. L: &glog.Logger{},
  17. Input: cwd,
  18. Output: filepath.Join(cwd, "public/"),
  19. }
  20. g := &gonf.Config{}
  21. g.Target(smd)
  22. g.Description("command line tool for generating static html from markdown")
  23. g.Add("web", "parse into individual files matching the original file name", "STATIC_WEB", "--web", "-w")
  24. g.Add("template", "path to user-defined template file", "STATIC_TEMPLATE", "--template", "-t:")
  25. g.Add("input", "path to the markdown files", "STATIC_INPUT", "--input", "-i:")
  26. g.Add("output", "path to place generated content", "STATIC_OUTPUT", "--output", "-o:")
  27. g.Add("version", "optional user-defined version", "STATIC_VERSION", "--version", "-v:")
  28. g.Example("-t template.tmpl -i . -b")
  29. g.Example("-t template.tmpl -i src/ -o out/ -r")
  30. g.Load()
  31. if err := smd.Run(operate); err != nil {
  32. exit(1)
  33. }
  34. }