Skip to content

Commit

Permalink
Allow root application to have a Run(...) error method.
Browse files Browse the repository at this point in the history
Issue #209
  • Loading branch information
tnarg authored and alecthomas committed Oct 15, 2021
1 parent 5c7b038 commit 749d3f0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down

0 comments on commit 749d3f0

Please sign in to comment.