Skip to content

Commit d6c8efa

Browse files
committed
Add flag of comma separated paths to ignore.
1 parent 59f4c52 commit d6c8efa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cmd/watcher/main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func main() {
2323
listFiles := flag.Bool("list", false, "list watched files on start")
2424
stdinPipe := flag.Bool("pipe", false, "pipe event's info to command's stdin")
2525
keepalive := flag.Bool("keepalive", false, "keep alive when a cmd returns code != 0")
26+
ignore := flag.String("ignore", "", "comma separated list of paths to ignore")
2627

2728
flag.Parse()
2829

@@ -52,6 +53,21 @@ func main() {
5253
w := watcher.New()
5354
w.IgnoreHiddenFiles(!*dotfiles)
5455

56+
// Get any of the paths to ignore.
57+
ignoredPaths := strings.Split(*ignore, ",")
58+
59+
for _, path := range ignoredPaths {
60+
trimmed := strings.TrimSpace(path)
61+
if trimmed == "" {
62+
continue
63+
}
64+
65+
err := w.Ignore(trimmed)
66+
if err != nil {
67+
log.Fatalln(err)
68+
}
69+
}
70+
5571
done := make(chan struct{})
5672
go func() {
5773
defer close(done)

0 commit comments

Comments
 (0)