(t *testing.T)
| 1109 | } |
| 1110 | |
| 1111 | func 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 | |
| 1138 | func TestCommand_CommandWithDash(t *testing.T) { |
| 1139 | var args Args |
nothing calls this directly
no test coverage detected