From 7c32580196b5e23d218a4fffe37058fcdc815bc5 Mon Sep 17 00:00:00 2001 From: Calum Gardner Date: Thu, 11 Aug 2016 20:31:43 +0100 Subject: [PATCH] Solo Execute --- command.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/command.go b/command.go index 083e4ea7..e1f3974f 100644 --- a/command.go +++ b/command.go @@ -645,17 +645,31 @@ func (c *Command) errorMsgFromParse() string { // and run through the command tree finding appropriate matches // for commands and then corresponding flags. func (c *Command) Execute() error { + if c.HasParent() { + _, err := c.Root().ExecuteC() + return err + } _, err := c.ExecuteC() return err } -func (c *Command) ExecuteC() (cmd *Command, err error) { +func (c *Command) ExecuteSolo() error { + _, err := c.executeC() + return err +} +func (c *Command) ExecuteC() (cmd *Command, err error) { // Regardless of what command execute is called on, run on Root only if c.HasParent() { - return c.Root().ExecuteC() - } + return c.Root().ExecuteC() + } + cmd, err = c.executeC() + return cmd, err +} + + +func (c *Command) executeC() (cmd *Command, err error) { // windows hook if preExecHookFn != nil { preExecHookFn(c)