(t *testing.T)
| 374 | } |
| 375 | |
| 376 | func TestHelpCompactNoExpand(t *testing.T) { |
| 377 | var cli struct { |
| 378 | One struct { |
| 379 | Thing struct { |
| 380 | Arg string `arg help:"argument"` |
| 381 | } `cmd help:"subcommand thing"` |
| 382 | Other struct { |
| 383 | Other string `arg help:"other arg"` |
| 384 | } `arg help:"subcommand other"` |
| 385 | } `cmd help:"subcommand one" group:"Group A" aliases:"un,uno"` // Groups are ignored in trees |
| 386 | |
| 387 | Two struct { |
| 388 | Three threeArg `arg help:"Sub-sub-arg."` |
| 389 | |
| 390 | Four struct{} `cmd help:"Sub-sub-command." aliases:"for,fore"` |
| 391 | } `cmd help:"Another subcommand."` |
| 392 | } |
| 393 | |
| 394 | w := bytes.NewBuffer(nil) |
| 395 | exited := false |
| 396 | app := mustNew(t, &cli, |
| 397 | kong.Name("test-app"), |
| 398 | kong.Description("A test app."), |
| 399 | kong.Writers(w, w), |
| 400 | kong.ConfigureHelp(kong.HelpOptions{ |
| 401 | Compact: true, |
| 402 | NoExpandSubcommands: true, |
| 403 | }), |
| 404 | kong.Exit(func(int) { |
| 405 | exited = true |
| 406 | panic(true) // Panic to fake "exit". |
| 407 | }), |
| 408 | ) |
| 409 | |
| 410 | t.Run("Full", func(t *testing.T) { |
| 411 | panicsTrue(t, func() { |
| 412 | _, err := app.Parse([]string{"--help"}) |
| 413 | assert.NoError(t, err) |
| 414 | }) |
| 415 | assert.True(t, exited) |
| 416 | expected := `Usage: test-app <command> |
| 417 | |
| 418 | A test app. |
| 419 | |
| 420 | Flags: |
| 421 | -h, --help Show context-sensitive help. |
| 422 | |
| 423 | Commands: |
| 424 | two Another subcommand. |
| 425 | |
| 426 | Group A |
| 427 | one (un,uno) subcommand one |
| 428 | |
| 429 | Run "test-app <command> --help" for more information on a command. |
| 430 | ` |
| 431 | if expected != w.String() { |
| 432 | t.Errorf("help command returned:\n%v\n\nwant:\n%v", w.String(), expected) |
| 433 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…