MCPcopy
hub / github.com/spf13/cobra / manPreamble

Function manPreamble

doc/man_docs.go:143–157  ·  view source on GitHub ↗
(buf io.StringWriter, header *GenManHeader, cmd *cobra.Command, dashedName string)

Source from the content-addressed store, hash-verified

141}
142
143func manPreamble(buf io.StringWriter, header *GenManHeader, cmd *cobra.Command, dashedName string) {
144 description := cmd.Long
145 if len(description) == 0 {
146 description = cmd.Short
147 }
148
149 cobra.WriteStringAndCheck(buf, fmt.Sprintf(`%% "%s" "%s" "%s" "%s" "%s"
150# NAME
151`, header.Title, header.Section, header.date, header.Source, header.Manual))
152 cobra.WriteStringAndCheck(buf, fmt.Sprintf("%s \\- %s\n\n", dashedName, cmd.Short))
153 cobra.WriteStringAndCheck(buf, "# SYNOPSIS\n")
154 cobra.WriteStringAndCheck(buf, fmt.Sprintf("**%s**\n\n", cmd.UseLine()))
155 cobra.WriteStringAndCheck(buf, "# DESCRIPTION\n")
156 cobra.WriteStringAndCheck(buf, description+"\n\n")
157}
158
159func manPrintFlags(buf io.StringWriter, flags *pflag.FlagSet) {
160 flags.VisitAll(func(flag *pflag.Flag) {

Callers 1

genManFunction · 0.85

Calls 2

WriteStringAndCheckFunction · 0.92
UseLineMethod · 0.80

Tested by

no test coverage detected