mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
Create hack folder with independent modules (#131)
This commit is contained in:
parent
cfad36720b
commit
8e0f9491af
12 changed files with 1810 additions and 11 deletions
32
hack/clidocgen/main.go
Normal file
32
hack/clidocgen/main.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Clidocgen generates a Markdown page describing all CLI commands.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/edgelesssys/constellation/cli/cmd"
|
||||
"github.com/spf13/cobra/doc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rootCmd := cmd.NewRootCmd()
|
||||
rootCmd.DisableAutoGenTag = true
|
||||
|
||||
// Generate Markdown for all commands.
|
||||
cmdList := &bytes.Buffer{}
|
||||
body := &bytes.Buffer{}
|
||||
for _, c := range rootCmd.Commands() {
|
||||
name := c.Name()
|
||||
fmt.Fprintf(cmdList, "* [%v](#constellation-%v): %v\n", name, name, c.Short)
|
||||
if err := doc.GenMarkdown(c, body); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove "see also" sections. They list parent and child commands, which is not interesting for us.
|
||||
cleanedBody := regexp.MustCompile(`(?s)### SEE ALSO\n.+?\n\n`).ReplaceAll(body.Bytes(), nil)
|
||||
|
||||
fmt.Printf("Commands:\n\n%s\n%s", cmdList, cleanedBody)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue