Skip to content

Commit

Permalink
Generate the documentation for all commands
Browse files Browse the repository at this point in the history
  • Loading branch information
GGP1 committed Dec 9, 2023
1 parent 22cff76 commit 8225db8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ func main() {
func cmdDocs(args []string) error {
root := root.NewCmd(nil)

if args[2] == "all" {
commands := root.Commands()
for _, c := range commands {
fmt.Println("#", c.Name())
if err := customMarkdown(c, os.Stdout); err != nil {
return err
}
fmt.Println("---")
}

return nil
}

cmd, _, err := root.Find(args[2:])
if err != nil {
return err
Expand All @@ -68,7 +81,7 @@ func customMarkdown(cmd *cobra.Command, w io.Writer) error {
return strings.Replace(s, old, new, n)
},
"visitFlags": func(cmd *cobra.Command) string {
return visitFlags(cmd)
return strings.TrimSpace(visitFlags(cmd))
},
"visitFlagsTable": func(cmd *cobra.Command) string {
buf := new(bytes.Buffer)
Expand Down

0 comments on commit 8225db8

Please sign in to comment.