mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-24 23:19:39 -05: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:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-to-docs:
|
publish-to-docs:
|
||||||
|
@ -21,7 +21,7 @@ func main() {
|
|||||||
// Generate Markdown for all commands.
|
// Generate Markdown for all commands.
|
||||||
cmdList := &bytes.Buffer{}
|
cmdList := &bytes.Buffer{}
|
||||||
body := &bytes.Buffer{}
|
body := &bytes.Buffer{}
|
||||||
for _, c := range rootCmd.Commands() {
|
for _, c := range allSubCommands(rootCmd) {
|
||||||
name := c.Name()
|
name := c.Name()
|
||||||
fmt.Fprintf(cmdList, "* [%v](#constellation-%v): %v\n", name, name, c.Short)
|
fmt.Fprintf(cmdList, "* [%v](#constellation-%v): %v\n", name, name, c.Short)
|
||||||
if err := doc.GenMarkdown(c, body); err != nil {
|
if err := doc.GenMarkdown(c, body); err != nil {
|
||||||
@ -34,3 +34,12 @@ func main() {
|
|||||||
|
|
||||||
fmt.Printf("Commands:\n\n%s\n%s", cmdList, cleanedBody)
|
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