defaultHelpFunc is equivalent to executing defaultHelpTemplate. The two should be changed in sync.
(w io.Writer, in interface{})
| 2045 | |
| 2046 | // defaultHelpFunc is equivalent to executing defaultHelpTemplate. The two should be changed in sync. |
| 2047 | func 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 | |
| 2064 | const defaultVersionTemplate = `{{with .DisplayName}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}} |
| 2065 | ` |
nothing calls this directly
no test coverage detected