mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
Generate CLI reference also for sub-commands (#374)
* include all subcommands Signed-off-by: Fabian Kammel <fk@edgeless.systems>
This commit is contained in:
parent
059a3eacc0
commit
4176f038df
2 changed files with 11 additions and 1 deletions
|
@ -21,7 +21,7 @@ func main() {
|
|||
// Generate Markdown for all commands.
|
||||
cmdList := &bytes.Buffer{}
|
||||
body := &bytes.Buffer{}
|
||||
for _, c := range rootCmd.Commands() {
|
||||
for _, c := range allSubCommands(rootCmd) {
|
||||
name := c.Name()
|
||||
fmt.Fprintf(cmdList, "* [%v](#constellation-%v): %v\n", name, name, c.Short)
|
||||
if err := doc.GenMarkdown(c, body); err != nil {
|
||||
|
@ -34,3 +34,12 @@ func main() {
|
|||
|
||||
fmt.Printf("Commands:\n\n%s\n%s", cmdList, cleanedBody)
|
||||
}
|
||||
|
||||
func allSubCommands(cmd *cobra.Command) []*cobra.Command {
|
||||
var all []*cobra.Command
|
||||
for _, c := range cmd.Commands() {
|
||||
all = append(all, c)
|
||||
all = append(all, allSubCommands(c)...)
|
||||
}
|
||||
return all
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue