Remove CategorizedHelp from App and allow subcommands to have categories

Just place all subcommands in categories, the default category will be
"" which will properly format the output (and group commands that have
no category).

Also allow subcommands to have categories.

Lastly, augment the test to check the output.
This commit is contained in:
Jesse Szwedko
2016-03-20 12:17:13 -07:00
parent d0997e8f99
commit 042842b819
4 changed files with 31 additions and 21 deletions

View File

@@ -943,7 +943,6 @@ func TestApp_Run_Version(t *testing.T) {
func TestApp_Run_Categories(t *testing.T) {
app := NewApp()
app.Name = "categories"
app.CategorizedHelp = true
app.Commands = []Command{
Command{
Name: "command1",
@@ -981,6 +980,13 @@ func TestApp_Run_Categories(t *testing.T) {
if !reflect.DeepEqual(app.Categories(), expect) {
t.Fatalf("expected categories %#v, to equal %#v", app.Categories(), expect)
}
output := buf.String()
t.Logf("output: %q\n", buf.Bytes())
if !strings.Contains(output, "1:\n command1") {
t.Errorf("want buffer to include category %q, did not: \n%q", "1:\n command1", output)
}
}
func TestApp_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {