MCPcopy
hub / github.com/abiosoft/ishell / HelpText

Method HelpText

command.go:76–101  ·  view source on GitHub ↗

HelpText returns the computed help of the command and its subcommands.

()

Source from the content-addressed store, hash-verified

74
75// HelpText returns the computed help of the command and its subcommands.
76func (c Cmd) HelpText() string {
77 var b bytes.Buffer
78 p := func(s ...interface{}) {
79 fmt.Fprintln(&b)
80 if len(s) > 0 {
81 fmt.Fprintln(&b, s...)
82 }
83 }
84 if c.LongHelp != "" {
85 p(c.LongHelp)
86 } else if c.Help != "" {
87 p(c.Help)
88 } else if c.Name != "" {
89 p(c.Name, "has no help")
90 }
91 if c.hasSubcommand() {
92 p("Commands:")
93 w := tabwriter.NewWriter(&b, 0, 4, 2, ' ', 0)
94 for _, child := range c.Children() {
95 fmt.Fprintf(w, "\t%s\t\t\t%s\n", child.Name, child.Help)
96 }
97 w.Flush()
98 p()
99 }
100 return b.String()
101}
102
103// findChildCmd returns the subcommand with matching name or alias.
104func (c *Cmd) findChildCmd(name string) *Cmd {

Callers

nothing calls this directly

Calls 2

hasSubcommandMethod · 0.95
ChildrenMethod · 0.95

Tested by

no test coverage detected