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

@ -1075,3 +1075,14 @@ func TestAddTemplateFunctions(t *testing.T) {
t.Errorf("c.UsageString() != \"%s\", is \"%s\"", usage, us)
}
}
func TestUsageIsNotPrintedTwice(t *testing.T) {
var cmd = &Command{Use: "root"}
var sub = &Command{Use: "sub"}
cmd.AddCommand(sub)
r := simpleTester(cmd, "")
if strings.Count(r.Output, "Usage:") != 1 {
t.Error("Usage output is not printed exactly once")
}
}