(w io.Writer, cmd *cobra.Command, depth int)
| 52 | } |
| 53 | |
| 54 | func cmdRef(w io.Writer, cmd *cobra.Command, depth int) { |
| 55 | // Name + Description |
| 56 | fmt.Fprintf(w, "%s `%s`\n\n", strings.Repeat("#", depth), cmd.UseLine()) |
| 57 | fmt.Fprintf(w, "%s\n\n", cmd.Short) |
| 58 | |
| 59 | // Flags |
| 60 | // TODO: fold in InheritedFlags/PersistentFlags, but omit `--help` due to repetitiveness |
| 61 | if flagUsages := cmd.Flags().FlagUsages(); flagUsages != "" { |
| 62 | fmt.Fprintf(w, "```\n%s````\n\n", dedent(flagUsages)) |
| 63 | } |
| 64 | |
| 65 | // Aliases |
| 66 | if len(cmd.Aliases) > 0 { |
| 67 | fmt.Fprintf(w, "%s\n\n", "Aliases") |
| 68 | fmt.Fprintf(w, "\n%s\n\n", dedent(strings.Join(BuildAliasList(cmd, cmd.Aliases), ", "))) |
| 69 | } |
| 70 | |
| 71 | // Subcommands |
| 72 | for _, c := range cmd.Commands() { |
| 73 | if c.Hidden { |
| 74 | continue |
| 75 | } |
| 76 | cmdRef(w, c, depth+1) |
| 77 | } |
| 78 | } |
no test coverage detected