Walk visits cmd and every descendant. If fn returns a non-nil error, the walk terminates and the error is returned to the caller.
(fn func(*Command) error)
| 585 | // Walk visits cmd and every descendant. If fn returns a non-nil error, the |
| 586 | // walk terminates and the error is returned to the caller. |
| 587 | func (cmd *Command) Walk(fn func(*Command) error) error { |
| 588 | if fn == nil { |
| 589 | return nil |
| 590 | } |
| 591 | if err := fn(cmd); err != nil { |
| 592 | return err |
| 593 | } |
| 594 | for _, sub := range cmd.Commands { |
| 595 | if err := sub.Walk(fn); err != nil { |
| 596 | return err |
| 597 | } |
| 598 | } |
| 599 | return nil |
| 600 | } |
| 601 | |
| 602 | // Count returns the num of occurrences of this flag |
| 603 | func (cmd *Command) Count(name string) int { |
no outgoing calls