From c083ee4f330ae41cd35080f00b6d78940d0df728 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Tue, 22 Oct 2024 21:46:54 +0300 Subject: [PATCH] Add Exec and Grouping commands to root node --- simple/menu.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/simple/menu.go b/simple/menu.go index ba324ac..0e16078 100644 --- a/simple/menu.go +++ b/simple/menu.go @@ -171,6 +171,20 @@ func (m *Menu) AddCommand(key, name string, action CommandAction) (*commandNode, return m.cmdTree.Root.AddCommand(key, name, action), nil } +func (m *Menu) AddExecCommand(key, name string, action CommandAction) (*commandNode, error) { + if m.cmdTree == nil { + return nil, CommandTree_notInit + } + return m.cmdTree.Root.AddExecCommand(key, name, action), nil +} + +func (m *Menu) AddGroupingCommand(key, name string) (*commandNode, error) { + if m.cmdTree == nil { + return nil, CommandTree_notInit + } + return m.cmdTree.Root.AddGroupingCommand(key, name), nil +} + func (m *Menu) clearLines() { for i := 0; i < int(m.lineCounter); i++ { fmt.Printf("\033[F\033[K")