#655 Validate Required Flags Before Prerun

This commit is contained in:
Amanpreet Singh 2018-06-01 12:38:27 +05:30
parent 1e58aa3361
commit 8d4f0c6c0f

View file

@ -736,6 +736,10 @@ func (c *Command) execute(a []string) (err error) {
return err
}
if err := c.validateRequiredFlags(); err != nil {
return err
}
for p := c; p != nil; p = p.Parent() {
if p.PersistentPreRunE != nil {
if err := p.PersistentPreRunE(c, argWoFlags); err != nil {
@ -747,6 +751,7 @@ func (c *Command) execute(a []string) (err error) {
break
}
}
if c.PreRunE != nil {
if err := c.PreRunE(c, argWoFlags); err != nil {
return err
@ -755,9 +760,6 @@ func (c *Command) execute(a []string) (err error) {
c.PreRun(c, argWoFlags)
}
if err := c.validateRequiredFlags(); err != nil {
return err
}
if c.RunE != nil {
if err := c.RunE(c, argWoFlags); err != nil {
return err