gitlab.com/Raven-IO/raven-delve@v1.22.4/_scripts/gen-usage-docs.go (about) 1 //go:build ignore 2 3 package main 4 5 import ( 6 "fmt" 7 "log" 8 "os" 9 "path/filepath" 10 11 "github.com/spf13/cobra/doc" 12 "gitlab.com/Raven-IO/raven-delve/cmd/dlv/cmds" 13 "gitlab.com/Raven-IO/raven-delve/cmd/dlv/cmds/helphelpers" 14 ) 15 16 const defaultUsageDir = "./Documentation/usage" 17 18 func main() { 19 usageDir := defaultUsageDir 20 if len(os.Args) > 1 { 21 usageDir = os.Args[1] 22 } 23 root := cmds.New(true) 24 25 cmdnames := []string{} 26 for _, subcmd := range root.Commands() { 27 cmdnames = append(cmdnames, subcmd.Name()) 28 } 29 helphelpers.Prepare(root) 30 doc.GenMarkdownTree(root, usageDir) 31 root = nil 32 // GenMarkdownTree ignores additional help topic commands, so we have to do this manually 33 for _, cmdname := range cmdnames { 34 cmd, _, _ := cmds.New(true).Find([]string{cmdname}) 35 helphelpers.Prepare(cmd) 36 doc.GenMarkdownTree(cmd, usageDir) 37 } 38 fh, err := os.OpenFile(filepath.Join(usageDir, "dlv.md"), os.O_APPEND|os.O_WRONLY, 0) 39 if err != nil { 40 log.Fatalf("appending to dlv.md: %v", err) 41 } 42 defer fh.Close() 43 fmt.Fprintln(fh, "* [dlv log](dlv_log.md)\t - Help about logging flags") 44 fmt.Fprintln(fh, "* [dlv backend](dlv_backend.md)\t - Help about the `--backend` flag") 45 }