mirror of
https://github.com/spf13/cobra
synced 2024-11-25 07:07:15 +00:00
#655 Validate Required Flags Before Prerun
This commit is contained in:
parent
1e58aa3361
commit
8d4f0c6c0f
1 changed files with 5 additions and 3 deletions
|
@ -736,6 +736,10 @@ func (c *Command) execute(a []string) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := c.validateRequiredFlags(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -747,6 +751,7 @@ func (c *Command) execute(a []string) (err error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.PreRunE != nil {
|
if c.PreRunE != nil {
|
||||||
if err := c.PreRunE(c, argWoFlags); err != nil {
|
if err := c.PreRunE(c, argWoFlags); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -755,9 +760,6 @@ func (c *Command) execute(a []string) (err error) {
|
||||||
c.PreRun(c, argWoFlags)
|
c.PreRun(c, argWoFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.validateRequiredFlags(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c.RunE != nil {
|
if c.RunE != nil {
|
||||||
if err := c.RunE(c, argWoFlags); err != nil {
|
if err := c.RunE(c, argWoFlags); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue