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 := &staticmd.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 deliverable static content")
  23. g.Add("template", "path to the template file", "STATICMD_TEMPLATE", "--template", "-t:")
  24. g.Add("input", "path to the markdown files", "STATICMD_INPUT", "--input", "-i:")
  25. g.Add("output", "path to place generated content", "STATICMD_OUTPUT", "--output", "-o:")
  26. g.Add("book", "combine all content into a single file", "STATICMD_BOOK", "--book", "-b")
  27. g.Add("relative", "use relative paths instead of absolute paths", "STATICMD_RELATIVE", "--relative", "-r")
  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.Generate(operate); err != nil {
  32. exit(1)
  33. }
  34. }