Skip to content

Commit f144d21

Browse files
committed
Add filter-name
1 parent 7cc022f commit f144d21

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

cmd/exec.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"os/exec"
99
"path/filepath"
10+
"regexp"
1011
"strings"
1112
"time"
1213

@@ -56,6 +57,7 @@ Example use:
5657
includeTransDependants, _ = cmd.Flags().GetBool("transitive-dependants")
5758
components, _ = cmd.Flags().GetBool("components")
5859
filterType, _ = cmd.Flags().GetStringArray("filter-type")
60+
filterName, _ = cmd.Flags().GetString("filter-name")
5961
watch, _ = cmd.Flags().GetBool("watch")
6062
parallel, _ = cmd.Flags().GetBool("parallel")
6163
rawOutput, _ = cmd.Flags().GetBool("raw-output")
@@ -131,6 +133,21 @@ Example use:
131133
}
132134
}
133135

136+
if filterName != "" {
137+
filterExpr, err := regexp.Compile(filterName)
138+
if err != nil {
139+
log.WithError(err).Fatal("invalid filter-name expression")
140+
}
141+
for pkg := range pkgs {
142+
if filterExpr.MatchString(pkg.FullName()) {
143+
continue
144+
}
145+
146+
log.WithField("package", pkg.FullName()).Debug("filtering out due to filter-name")
147+
delete(pkgs, pkg)
148+
}
149+
}
150+
134151
spkgs := make([]*leeway.Package, 0, len(pkgs))
135152
for p := range pkgs {
136153
spkgs = append(spkgs, p)
@@ -305,6 +322,7 @@ func init() {
305322
execCmd.Flags().Bool("transitive-dependants", false, "select transitive package dependants")
306323
execCmd.Flags().Bool("components", false, "select the package's components (e.g. instead of selecting three packages from the same component, execute just once in the component origin)")
307324
execCmd.Flags().StringArray("filter-type", nil, "only select packages of this type")
325+
execCmd.Flags().String("filter-name", "", "only select packages matching this name regular expression")
308326
execCmd.Flags().Bool("watch", false, "Watch source files and re-execute on change")
309327
execCmd.Flags().Bool("parallel", false, "Start all executions in parallel independent of their order")
310328
execCmd.Flags().Bool("raw-output", false, "Produce output without package prefix")

0 commit comments

Comments
 (0)