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

Method UsageString

command.go:526–542  ·  view source on GitHub ↗

UsageString returns usage string.

()

Source from the content-addressed store, hash-verified

524
525// UsageString returns usage string.
526func (c *Command) UsageString() string {
527 // Storing normal writers
528 tmpOutput := c.outWriter
529 tmpErr := c.errWriter
530
531 bb := new(bytes.Buffer)
532 c.outWriter = bb
533 c.errWriter = bb
534
535 CheckErr(c.Usage())
536
537 // Setting things back to normal
538 c.outWriter = tmpOutput
539 c.errWriter = tmpErr
540
541 return bb.String()
542}
543
544// FlagErrorFunc returns either the function set by SetFlagErrorFunc for this
545// command or a parent, or it returns a function which returns the original

Callers 4

TestAddTemplateFunctionsFunction · 0.95
ExecuteCMethod · 0.80
defaultHelpFuncFunction · 0.80

Calls 3

UsageMethod · 0.95
CheckErrFunction · 0.85
StringMethod · 0.80

Tested by 2

TestAddTemplateFunctionsFunction · 0.76