From 749d3f0752b5ee005551041230343b0239592f3f Mon Sep 17 00:00:00 2001 From: Grant Monroe Date: Thu, 14 Oct 2021 16:22:59 -0700 Subject: [PATCH] Allow root application to have a Run(...) error method. Issue #209 --- context.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/context.go b/context.go index 21c4bf6..41a1ea7 100644 --- a/context.go +++ b/context.go @@ -742,6 +742,15 @@ func (c *Context) RunNode(node *Node, binds ...interface{}) (err error) { func (c *Context) Run(binds ...interface{}) (err error) { node := c.Selected() if node == nil { + if len(c.Path) > 0 { + selected := c.Path[0].Node() + if selected.Type == ApplicationNode { + method := getMethod(selected.Target, "Run") + if method.IsValid() { + return c.RunNode(selected, binds...) + } + } + } return fmt.Errorf("no command selected") } return c.RunNode(node, binds...)