mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -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
1
.github/workflows/update-cli-reference.yml
vendored
1
.github/workflows/update-cli-reference.yml
vendored
@ -3,6 +3,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish-to-docs:
|
||||
|
@ -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…
Reference in New Issue
Block a user