-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (36 loc) · 804 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package main
import (
"fmt"
"os"
"github.com/dkolb/ssmtoyaml/cmd"
"github.com/dkolb/ssmtoyaml/utils"
"github.com/spf13/cobra/doc"
)
func main() {
if os.Getenv("GEN_DOCS") == "makeitso" {
generateDocs()
} else {
cmd.Execute()
}
}
func generateDocs() {
dir := utils.EnvWithDefault("GEN_DOCS_DIR", "./docs")
linkPrefix := utils.EnvWithDefault("GEN_DOCS_LINK_PREFIX", "docs/")
ssmtoyaml := cmd.GetRootCmd()
err := doc.GenMarkdownTreeCustom(
ssmtoyaml,
dir,
func(filename string) string { return "" },
func(name string) string { return linkPrefix + name },
)
if err != nil {
panic(err)
}
if err != nil {
fmt.Fprintf(os.Stderr, "Doc generation failed with error: %v\n", err)
}
fmt.Fprintln(os.Stderr, "Docs generated.")
}