MCPcopy
hub / github.com/urfave/cli / TestCommand_UseShortOptionHandling

Function TestCommand_UseShortOptionHandling

command_test.go:1246–1269  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1244}
1245
1246func TestCommand_UseShortOptionHandling(t *testing.T) {
1247 var one, two bool
1248 var name string
1249 expected := "expectedName"
1250
1251 cmd := buildMinimalTestCommand()
1252 cmd.UseShortOptionHandling = true
1253 cmd.Flags = []Flag{
1254 &BoolFlag{Name: "one", Aliases: []string{"o"}},
1255 &BoolFlag{Name: "two", Aliases: []string{"t"}},
1256 &StringFlag{Name: "name", Aliases: []string{"n"}},
1257 }
1258 cmd.Action = func(_ context.Context, cmd *Command) error {
1259 one = cmd.Bool("one")
1260 two = cmd.Bool("two")
1261 name = cmd.String("name")
1262 return nil
1263 }
1264
1265 _ = cmd.Run(buildTestContext(t), []string{"", "-on", expected})
1266 assert.True(t, one)
1267 assert.False(t, two)
1268 assert.Equal(t, name, expected)
1269}
1270
1271func TestCommand_UseShortOptionHandling_missing_value(t *testing.T) {
1272 cmd := buildMinimalTestCommand()

Callers

nothing calls this directly

Calls 5

buildMinimalTestCommandFunction · 0.85
buildTestContextFunction · 0.85
BoolMethod · 0.80
StringMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected