Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-07-31 00:20:27 +02:00 коммит произвёл Sebastiaan van Stijn
Родитель 8a505799c6
Коммит 70265e4072
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 76698F39D527CE8C
3 изменённых файлов: 22 добавлений и 23 удалений

Просмотреть файл

@ -1,7 +1,6 @@
[![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/docker/docgen)
[![Test Status](https://img.shields.io/github/workflow/status/crazy-max/docgen/build?label=build&logo=github&style=flat-square)](https://github.com/docker/docgen/actions?query=workflow%3Atest)
[![Go Report Card](https://goreportcard.com/badge/github.com/docker/docgen)](https://goreportcard.com/report/github.com/docker/docgen)
[![Codecovs](https://img.shields.io/codecov/c/github/crazy-max/docgen?logo=codecov&style=flat-square)](https://codecov.io/gh/crazy-max/docgen)
## About

Просмотреть файл

@ -1,22 +0,0 @@
package docgen
import "github.com/spf13/cobra"
// VisitAll will traverse all commands from the root.
// This is different from the VisitAll of cobra.Command where only parents
// are checked.
func VisitAll(root *cobra.Command, fn func(*cobra.Command)) {
for _, cmd := range root.Commands() {
VisitAll(cmd, fn)
}
fn(root)
}
// DisableFlagsInUseLine sets the DisableFlagsInUseLine flag on all
// commands within the tree rooted at cmd.
func DisableFlagsInUseLine(cmd *cobra.Command) {
VisitAll(cmd, func(ccmd *cobra.Command) {
// do not add a `[flags]` to the end of the usage line.
ccmd.DisableFlagsInUseLine = true
})
}

Просмотреть файл

@ -4,6 +4,9 @@ import (
"github.com/spf13/cobra"
)
// GenTree creates yaml and markdown structured ref files for this command
// and all descendants in the directory given. This function will just
// call GenMarkdownTree and GenYamlTree functions successively.
func GenTree(cmd *cobra.Command, dir string) error {
var err error
if err = GenMarkdownTree(cmd, dir); err != nil {
@ -14,3 +17,22 @@ func GenTree(cmd *cobra.Command, dir string) error {
}
return nil
}
// VisitAll will traverse all commands from the root.
// This is different from the VisitAll of cobra.Command where only parents
// are checked.
func VisitAll(root *cobra.Command, fn func(*cobra.Command)) {
for _, cmd := range root.Commands() {
VisitAll(cmd, fn)
}
fn(root)
}
// DisableFlagsInUseLine sets the DisableFlagsInUseLine flag on all
// commands within the tree rooted at cmd.
func DisableFlagsInUseLine(cmd *cobra.Command) {
VisitAll(cmd, func(ccmd *cobra.Command) {
// do not add a `[flags]` to the end of the usage line.
ccmd.DisableFlagsInUseLine = true
})
}