Skip to content

Commit 107f2ac

Browse files
committed
Use StringSliceFlag instead of comma separated filters
1 parent 67042e0 commit 107f2ac

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

cmd/commander/commander.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ func createTestCommand() cli.Command {
6363
Name: "dir",
6464
Usage: "Execute all test files in a directory sorted by file name, this is not recursive - e.g. /path/to/test_files/",
6565
},
66-
cli.StringFlag{
66+
cli.StringSliceFlag{
6767
Name: "filter",
6868
Usage: `Filter tests by a given regex pattern. Tests are filtered by its title.
6969
7070
Example:
7171
test commander.yaml --filter="my test"
7272
73-
Apply multiple filters separated by commas:
74-
test commander.yaml --filter=filter1,filter2
73+
Apply multiple filters:
74+
test commander.yaml --filter=filter1 --filter=filter2
7575
`,
7676
},
7777
},

commander_unix.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ tests:
102102
exit-code: 0
103103

104104
test mulitple filters:
105-
command: ./commander test integration/unix/filter_test.yaml --filter="executed$,should be ignored"
105+
command: ./commander test integration/unix/filter_test.yaml --filter="executed$" --filter="should be ignored"
106106
stdout:
107107
contains:
108108
- ✓ [local] should be executed

pkg/app/app.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package app
22

33
import (
44
"github.com/urfave/cli"
5-
"strings"
65
)
76

87
const (
@@ -23,16 +22,11 @@ type AddCommandContext struct {
2322

2423
//NewAddContextFromCli is a constructor which creates the context
2524
func NewAddContextFromCli(c *cli.Context) AddCommandContext {
26-
filters := strings.Split(c.String("filter"), ",")
27-
if filters[0] == "" {
28-
filters = make([]string, 0)
29-
}
30-
3125
return AddCommandContext{
3226
Verbose: c.Bool("verbose"),
3327
NoColor: c.Bool("no-color"),
3428
Dir: c.Bool("dir"),
3529
Concurrent: c.Int("concurrent"),
36-
Filters: filters,
30+
Filters: c.StringSlice("filter"),
3731
}
3832
}

0 commit comments

Comments
 (0)