(t *testing.T)
| 1280 | } |
| 1281 | |
| 1282 | func TestCommand_UseShortOptionHandlingCommand(t *testing.T) { |
| 1283 | var ( |
| 1284 | one, two bool |
| 1285 | name string |
| 1286 | expected = "expectedName" |
| 1287 | ) |
| 1288 | |
| 1289 | cmd := &Command{ |
| 1290 | Name: "cmd", |
| 1291 | Flags: []Flag{ |
| 1292 | &BoolFlag{Name: "one", Aliases: []string{"o"}}, |
| 1293 | &BoolFlag{Name: "two", Aliases: []string{"t"}}, |
| 1294 | &StringFlag{Name: "name", Aliases: []string{"n"}}, |
| 1295 | }, |
| 1296 | Action: func(_ context.Context, cmd *Command) error { |
| 1297 | one = cmd.Bool("one") |
| 1298 | two = cmd.Bool("two") |
| 1299 | name = cmd.String("name") |
| 1300 | return nil |
| 1301 | }, |
| 1302 | UseShortOptionHandling: true, |
| 1303 | Writer: io.Discard, |
| 1304 | } |
| 1305 | |
| 1306 | require.NoError(t, cmd.Run(buildTestContext(t), []string{"cmd", "-on", expected})) |
| 1307 | require.True(t, one) |
| 1308 | require.False(t, two) |
| 1309 | require.Equal(t, expected, name) |
| 1310 | } |
| 1311 | |
| 1312 | func TestCommand_UseShortOptionHandlingCommand_missing_value(t *testing.T) { |
| 1313 | cmd := buildMinimalTestCommand() |
nothing calls this directly
no test coverage detected