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

Method DebugFlags

command.go:1501–1538  ·  view source on GitHub ↗

DebugFlags used to determine which flags have been assigned to which commands and which persist.

()

Source from the content-addressed store, hash-verified

1499// DebugFlags used to determine which flags have been assigned to which commands
1500// and which persist.
1501func (c *Command) DebugFlags() {
1502 c.Println("DebugFlags called on", c.Name())
1503 var debugflags func(*Command)
1504
1505 debugflags = func(x *Command) {
1506 if x.HasFlags() || x.HasPersistentFlags() {
1507 c.Println(x.Name())
1508 }
1509 if x.HasFlags() {
1510 x.flags.VisitAll(func(f *flag.Flag) {
1511 if x.HasPersistentFlags() && x.persistentFlag(f.Name) != nil {
1512 c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [LP]")
1513 } else {
1514 c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [L]")
1515 }
1516 })
1517 }
1518 if x.HasPersistentFlags() {
1519 x.pflags.VisitAll(func(f *flag.Flag) {
1520 if x.HasFlags() {
1521 if x.flags.Lookup(f.Name) == nil {
1522 c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [P]")
1523 }
1524 } else {
1525 c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [P]")
1526 }
1527 })
1528 }
1529 c.Println(x.flagErrorBuf)
1530 if x.HasSubCommands() {
1531 for _, y := range x.commands {
1532 debugflags(y)
1533 }
1534 }
1535 }
1536
1537 debugflags(c)
1538}
1539
1540// Name returns the command's name: the first word in the use line.
1541func (c *Command) Name() string {

Callers

nothing calls this directly

Calls 6

PrintlnMethod · 0.95
NameMethod · 0.95
HasFlagsMethod · 0.80
HasPersistentFlagsMethod · 0.80
persistentFlagMethod · 0.80
HasSubCommandsMethod · 0.80

Tested by

no test coverage detected