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

Function TestCommand_CommandWithFlagBeforeTerminator

command_test.go:1111–1136  ·  command_test.go::TestCommand_CommandWithFlagBeforeTerminator
(t *testing.T)

Source from the content-addressed store, hash-verified

1109}
1110
1111func TestCommand_CommandWithFlagBeforeTerminator(t *testing.T) {
1112 var parsedOption string
1113 var args Args
1114
1115 cmd := &Command{
1116 Commands: []*Command{
1117 {
1118 Name: "cmd",
1119 Flags: []Flag{
1120 &StringFlag{Name: "option", Value: "", Usage: "some option"},
1121 },
1122 Action: func(_ context.Context, cmd *Command) error {
1123 parsedOption = cmd.String("option")
1124 args = cmd.Args()
1125 return nil
1126 },
1127 },
1128 },
1129 }
1130
1131 require.NoError(t, cmd.Run(buildTestContext(t), []string{"", "cmd", "--option", "my-option", "my-arg", "--", "--notARealFlag"}))
1132
1133 require.Equal(t, "my-option", parsedOption)
1134 require.Equal(t, "my-arg", args.Get(0))
1135 require.Equal(t, "--notARealFlag", args.Get(1))
1136}
1137
1138func TestCommand_CommandWithDash(t *testing.T) {
1139 var args Args

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
ArgsMethod · 0.95
RunMethod · 0.95
GetMethod · 0.95
buildTestContextFunction · 0.85

Tested by

no test coverage detected