mirror of
https://github.com/spf13/cobra
synced 2024-11-16 18:57:08 +00:00
Modify the logic of Command execute function
Signed-off-by: Dong Gang <dong.gang@daocloud.io>
This commit is contained in:
parent
01ce53c87a
commit
f5ce802946
1 changed files with 6 additions and 6 deletions
12
command.go
12
command.go
|
@ -801,12 +801,6 @@ func (c *Command) execute(a []string) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
if !c.Runnable() {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
c.preRun()
|
||||
|
||||
argWoFlags := c.Flags().Args()
|
||||
if c.DisableFlagParsing {
|
||||
argWoFlags = a
|
||||
|
@ -816,6 +810,12 @@ func (c *Command) execute(a []string) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if !c.Runnable() {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
c.preRun()
|
||||
|
||||
for p := c; p != nil; p = p.Parent() {
|
||||
if p.PersistentPreRunE != nil {
|
||||
if err := p.PersistentPreRunE(c, argWoFlags); err != nil {
|
||||
|
|
Loading…
Reference in a new issue