Ensure the usage command is printed only once

Reverse a swap in logic introduced in #169 that would cause the usage
output to be printed twice.

Fixes #171
This commit is contained in:
James Bowes
2015-10-31 10:22:19 -03:00
parent 24562666ea
commit 871b0edae2
2 changed files with 17 additions and 5 deletions

View File

@ -639,11 +639,6 @@ func (c *Command) Execute() (err error) {
err = cmd.execute(flags)
if err != nil {
// If root command has SilentUsage flagged,
// all subcommands should respect it
if !cmd.SilenceUsage && !c.SilenceUsage {
c.Println(cmd.UsageString())
}
// If root command has SilentErrors flagged,
// all subcommands should respect it
if !cmd.SilenceErrors && !c.SilenceErrors {
@ -653,6 +648,12 @@ func (c *Command) Execute() (err error) {
}
c.Println("Error:", err.Error())
}
// If root command has SilentUsage flagged,
// all subcommands should respect it
if !cmd.SilenceUsage && !c.SilenceUsage {
c.Println(cmd.UsageString())
}
return err
}
return