mirror of
https://github.com/spf13/cobra
synced 2024-11-16 10:47:09 +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()
|
argWoFlags := c.Flags().Args()
|
||||||
if c.DisableFlagParsing {
|
if c.DisableFlagParsing {
|
||||||
argWoFlags = a
|
argWoFlags = a
|
||||||
|
@ -816,6 +810,12 @@ func (c *Command) execute(a []string) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !c.Runnable() {
|
||||||
|
return flag.ErrHelp
|
||||||
|
}
|
||||||
|
|
||||||
|
c.preRun()
|
||||||
|
|
||||||
for p := c; p != nil; p = p.Parent() {
|
for p := c; p != nil; p = p.Parent() {
|
||||||
if p.PersistentPreRunE != nil {
|
if p.PersistentPreRunE != nil {
|
||||||
if err := p.PersistentPreRunE(c, argWoFlags); err != nil {
|
if err := p.PersistentPreRunE(c, argWoFlags); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue