Skip to content
Myr

Fixed Persistent-Run function propagation

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Anastasis Andronidis · committed by Anastasis Andronidis · parent 3ee9552 · Browse files · 1 file+10 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−12 removed

  • other:+10 added−12 removed

1 file+10 added−12 removed

modified:command.go+10 added-12 removed
461 unmodified lines
462463 c.preRun()464 argWoFlags := c.Flags().Args()465466 for p := c; p != nil; p = p.Parent() {466 if c.PersistentPreRun != nil {467 c.PersistentPreRun(c, argWoFlags)467 if p.PersistentPreRun != nil {468 p.PersistentPreRun(c, argWoFlags)469 break470 }471 }472 if c.PreRun != nil {473 c.PreRun(c, argWoFlags)474 }
2 unmodified lines
477478 if c.PostRun != nil {479 c.PostRun(c, argWoFlags)480 }481 for p := c; p != nil; p = p.Parent() {478 if c.PersistentPostRun != nil {479 c.PersistentPostRun(c, argWoFlags)482 if p.PersistentPostRun != nil {483 p.PersistentPostRun(c, argWoFlags)484 break485 }486 }487488 return nil489}
116 unmodified lines
606 if nameLen > c.commandsMaxNameLen {607 c.commandsMaxNameLen = nameLen608 }609 c.commands = append(c.commands, x)604605 // Pass on peristent pre/post functions to children606 if x.PersistentPreRun == nil {607 x.PersistentPreRun = c.PersistentPreRun608 }609 if x.PersistentPostRun == nil {610 x.PersistentPostRun = c.PersistentPostRun611 }610 }611}612613// AddCommand removes one or more commands from a parent command.
390 unmodified lines