Skip to content

Commit

Permalink
Add flag of comma separated paths to ignore.
Browse files Browse the repository at this point in the history
  • Loading branch information
radovskyb committed Dec 12, 2018
1 parent 59f4c52 commit d6c8efa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func main() {
listFiles := flag.Bool("list", false, "list watched files on start")
stdinPipe := flag.Bool("pipe", false, "pipe event's info to command's stdin")
keepalive := flag.Bool("keepalive", false, "keep alive when a cmd returns code != 0")
ignore := flag.String("ignore", "", "comma separated list of paths to ignore")

flag.Parse()

Expand Down Expand Up @@ -52,6 +53,21 @@ func main() {
w := watcher.New()
w.IgnoreHiddenFiles(!*dotfiles)

// Get any of the paths to ignore.
ignoredPaths := strings.Split(*ignore, ",")

for _, path := range ignoredPaths {
trimmed := strings.TrimSpace(path)
if trimmed == "" {
continue
}

err := w.Ignore(trimmed)
if err != nil {
log.Fatalln(err)
}
}

done := make(chan struct{})
go func() {
defer close(done)
Expand Down

0 comments on commit d6c8efa

Please sign in to comment.