diff --git a/framework/state.go b/framework/state.go index 8db7a78..a3da5f8 100644 --- a/framework/state.go +++ b/framework/state.go @@ -54,8 +54,12 @@ func (s *CmdState) SetLabel(label string) { // Spawn returns a child command connected to current state as parent. func (s *CmdState) Spawn(label string) *CmdState { + p := s + for p.parent != nil { + p = p.parent + } return &CmdState{ - parent: s, + parent: p, label: label, } }