Ensure that '--version' flag works properly for root command (#595)
Make it so that, in the case that the root command is not runnable but has subcommands, specifying a '--version' flag will still run the "version" behavior.
This commit is contained in:
committed by
Albert Nigmatzianov
parent
c156af3984
commit
ccaecb155a
@ -685,7 +685,7 @@ func (c *Command) execute(a []string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if helpVal || !c.Runnable() {
|
||||
if helpVal {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
@ -705,6 +705,10 @@ func (c *Command) execute(a []string) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if !c.Runnable() {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
c.preRun()
|
||||
|
||||
argWoFlags := c.Flags().Args()
|
||||
|
Reference in New Issue
Block a user