1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-31 01:53:50 +02:00
goreleaser/cmd/docs.go
Ville Skyttä 1c9b4d56b4
feat: completion improvements (#4071)
See individual commits for details.
2023-06-06 00:21:17 -03:00

37 lines
834 B
Go

package cmd
import (
"strings"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
type docsCmd struct {
cmd *cobra.Command
}
func newDocsCmd() *docsCmd {
root := &docsCmd{}
cmd := &cobra.Command{
Use: "docs",
Short: "Generates GoReleaser's command line docs",
SilenceUsage: true,
DisableFlagsInUseLine: true,
Hidden: true,
Args: cobra.NoArgs,
ValidArgsFunction: cobra.NoFileCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
root.cmd.Root().DisableAutoGenTag = true
return doc.GenMarkdownTreeCustom(root.cmd.Root(), "www/docs/cmd", func(_ string) string {
return ""
}, func(s string) string {
return "/cmd/" + strings.TrimSuffix(s, ".md") + "/"
})
},
}
root.cmd = cmd
return root
}