Permalink
Browse files

cmd/zonedb: -exclude-tags option

  • Loading branch information...
ydnar committed May 22, 2018
1 parent 7511ca3 commit 2ede83c0b1e369e36f5ca5c15c4d77ab74c8ddbb
Showing with 19 additions and 4 deletions.
  1. +19 −4 cmd/zonedb/main.go
@@ -25,6 +25,7 @@ func main() {
filterRegexp := flag.String("x", "", "filter working zones by regular expression")
filterGrep := flag.String("grep", "", "filter working zones by regular expression across all metadata")
filterTags := flag.String("tags", "", "filter working zones by tags (comma-delimited)")
excludeTags := flag.String("exclude-tags", "", "exclude working zones with tags (comma-delimited)")
// Query operations
listZones := flag.Bool("list", false, "list working zones")
@@ -131,12 +132,11 @@ func main() {
}
if *filterTags != "" {
tags := strings.Split(*filterTags, ",")
tags := build.NewSet(strings.Split(*filterTags, ",")...)
filtered := make(map[string]*build.Zone, len(workZones))
for d, z := range workZones {
s := build.NewSet(z.Tags...)
for _, t := range tags {
if _, ok := s[t]; ok {
for _, t := range z.Tags {
if _, ok := tags[t]; ok {
filtered[d] = z
break
}
@@ -145,6 +145,21 @@ func main() {
workZones = filtered
}
if *excludeTags != "" {
tags := build.NewSet(strings.Split(*excludeTags, ",")...)
filtered := make(map[string]*build.Zone, len(workZones))
for d, z := range workZones {
filtered[d] = z
for _, t := range z.Tags {
if _, ok := tags[t]; ok {
delete(filtered, d)
break
}
}
}
workZones = filtered
}
color.Fprintf(os.Stderr, "@{.}Working on %d zone(s) out of %d\n", len(workZones), len(zones))
// Add newly found zones?

0 comments on commit 2ede83c

Please sign in to comment.