main.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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("title", "the title to give to the processed files", "STATIC_TITLE", "--title", "-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.Add("template", "path to user-defined template file", "STATIC_TEMPLATE", "--template")
  29. g.Example("-t template.tmpl -i . -b")
  30. g.Example("-t template.tmpl -i src/ -o out/ -r")
  31. g.Load()
  32. if err := smd.Run(operate); err != nil {
  33. exit(1)
  34. }
  35. }