| 6428 | } |
| 6429 | |
| 6430 | func TestCommand_Walk_Hidden(t *testing.T) { |
| 6431 | subCmd := &Command{Name: "bar", HideHelp: true} |
| 6432 | subSubCmd := &Command{Name: "baz"} |
| 6433 | subCmd.Commands = []*Command{subSubCmd} |
| 6434 | |
| 6435 | cmd := &Command{ |
| 6436 | Name: "foo", |
| 6437 | Commands: []*Command{subCmd}, |
| 6438 | } |
| 6439 | |
| 6440 | var visited []string |
| 6441 | err := cmd.Walk(func(c *Command) error { |
| 6442 | visited = append(visited, c.Name) |
| 6443 | return nil |
| 6444 | }) |
| 6445 | require.NoError(t, err) |
| 6446 | assert.Equal(t, []string{"foo", "bar", "baz"}, visited) |
| 6447 | } |
| 6448 | |
| 6449 | func TestCommand_Walk_NilFn(t *testing.T) { |
| 6450 | cmd := &Command{Name: "foo"} |