(t *testing.T)
| 1328 | } |
| 1329 | |
| 1330 | func TestCommand_UseShortOptionHandlingSubCommand(t *testing.T) { |
| 1331 | var one, two bool |
| 1332 | var name string |
| 1333 | |
| 1334 | cmd := buildMinimalTestCommand() |
| 1335 | cmd.UseShortOptionHandling = true |
| 1336 | cmd.Commands = []*Command{ |
| 1337 | { |
| 1338 | Name: "cmd", |
| 1339 | Commands: []*Command{ |
| 1340 | { |
| 1341 | Name: "sub", |
| 1342 | Flags: []Flag{ |
| 1343 | &BoolFlag{Name: "one", Aliases: []string{"o"}}, |
| 1344 | &BoolFlag{Name: "two", Aliases: []string{"t"}}, |
| 1345 | &StringFlag{Name: "name", Aliases: []string{"n"}}, |
| 1346 | }, |
| 1347 | Action: func(_ context.Context, cmd *Command) error { |
| 1348 | one = cmd.Bool("one") |
| 1349 | two = cmd.Bool("two") |
| 1350 | name = cmd.String("name") |
| 1351 | return nil |
| 1352 | }, |
| 1353 | }, |
| 1354 | }, |
| 1355 | }, |
| 1356 | } |
| 1357 | |
| 1358 | expected := "expectedName" |
| 1359 | |
| 1360 | require.NoError(t, cmd.Run(buildTestContext(t), []string{"", "cmd", "sub", "-on", expected})) |
| 1361 | require.True(t, one) |
| 1362 | require.False(t, two) |
| 1363 | require.Equal(t, expected, name) |
| 1364 | } |
| 1365 | |
| 1366 | func TestCommand_UseShortOptionHandlingSubCommand_missing_value(t *testing.T) { |
| 1367 | cmd := buildMinimalTestCommand() |
nothing calls this directly
no test coverage detected