UseLine puts out the full usage for a given command (including parents).
()
| 1480 | |
| 1481 | // UseLine puts out the full usage for a given command (including parents). |
| 1482 | func (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. |