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

Method UseLine

command.go:1482–1497  ·  view source on GitHub ↗

UseLine puts out the full usage for a given command (including parents).

()

Source from the content-addressed store, hash-verified

1480
1481// UseLine puts out the full usage for a given command (including parents).
1482func (c *Command) UseLine() string {
1483 var useline string
1484 use := strings.Replace(c.Use, c.Name(), c.DisplayName(), 1)
1485 if c.HasParent() {
1486 useline = c.parent.CommandPath() + " " + use
1487 } else {
1488 useline = use
1489 }
1490 if c.DisableFlagsInUseLine {
1491 return useline
1492 }
1493 if c.HasAvailableFlags() && !strings.Contains(useline, "[flags]") {
1494 useline += " [flags]"
1495 }
1496 return useline
1497}
1498
1499// DebugFlags used to determine which flags have been assigned to which commands
1500// and which persist.

Callers 7

TestSetHelpTemplateFunction · 0.95
TestSetUsageTemplateFunction · 0.95
defaultUsageFuncFunction · 0.80
manPreambleFunction · 0.80
GenYamlCustomFunction · 0.80
GenReSTCustomFunction · 0.80
GenMarkdownCustomFunction · 0.80

Calls 5

NameMethod · 0.95
DisplayNameMethod · 0.95
HasParentMethod · 0.95
HasAvailableFlagsMethod · 0.95
CommandPathMethod · 0.80

Tested by 2

TestSetHelpTemplateFunction · 0.76
TestSetUsageTemplateFunction · 0.76