tmpl/docs.go
John Olheiser c173eee38c
All checks were successful
continuous-integration/drone/push Build is passing
Explain .tmplkeep (#17)
Co-authored-by: jolheiser <john.olheiser@gmail.com>
Reviewed-on: #17
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-committed-by: John Olheiser <john.olheiser@gmail.com>
2021-01-03 11:29:37 +08:00

37 lines
559 B
Go

// +build docs
package main
import (
"os"
"regexp"
"strings"
"go.jolheiser.com/tmpl/cmd"
)
func main() {
app := cmd.NewApp()
fi, err := os.Create("CLI.md")
if err != nil {
panic(err)
}
defer fi.Close()
md, err := app.ToMarkdown()
if err != nil {
panic(err)
}
// CLI ToMarkdown issue related to man-pages
md = md[strings.Index(md, "#"):]
// CLI is using real default instead of DefaultText
md = regexp.MustCompile(`[\/\\:\w]+\.tmpl`).ReplaceAllString(md, "~/.tmpl")
if _, err := fi.WriteString(md); err != nil {
panic(err)
}
}