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

Function defaultHelpFunc

command.go:2047–2062  ·  view source on GitHub ↗

defaultHelpFunc is equivalent to executing defaultHelpTemplate. The two should be changed in sync.

(w io.Writer, in interface{})

Source from the content-addressed store, hash-verified

2045
2046// defaultHelpFunc is equivalent to executing defaultHelpTemplate. The two should be changed in sync.
2047func defaultHelpFunc(w io.Writer, in interface{}) error {
2048 c := in.(*Command)
2049 usage := c.Long
2050 if usage == "" {
2051 usage = c.Short
2052 }
2053 usage = trimRightSpace(usage)
2054 if usage != "" {
2055 fmt.Fprintln(w, usage)
2056 fmt.Fprintln(w)
2057 }
2058 if c.Runnable() || c.HasSubCommands() {
2059 fmt.Fprint(w, c.UsageString())
2060 }
2061 return nil
2062}
2063
2064const defaultVersionTemplate = `{{with .DisplayName}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}}
2065`

Callers

nothing calls this directly

Calls 4

trimRightSpaceFunction · 0.85
RunnableMethod · 0.80
HasSubCommandsMethod · 0.80
UsageStringMethod · 0.80

Tested by

no test coverage detected