From 29fa4d1c57eb7f3cc290d8c79d5bea0994eed885 Mon Sep 17 00:00:00 2001 From: congqixia Date: Fri, 11 Aug 2023 14:19:24 +0800 Subject: [PATCH] Fix multi generation cmd logic error (#182) Signed-off-by: Congqi Xia --- framework/state.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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, } }