Recursive watches can be added by using a "/..." parameter, similar to
the Go command:
w.Add("dir") // Behaves as before.
w.Add("dir/...") // Watch dir and all paths underneath it.
w.Remove("dir") // Remove the watch for dir and, if
// recursive, all paths underneath it too
w.Remove("dir/...") // Behaves like just "dir" if the path was
// recursive, error otherwise (probably
// want to add recursive remove too at some
// point).
The advantage of using "/..." vs. an option is that it can be easily
specified in configuration files and the like; for example from a TOML
file:
[watches]
dirs = ["/tmp/one", "/tmp/two/..."]
Options for this were previously discussed at:
https://github.com/fsnotify/fsnotify/pull/339#discussion_r788246013
This should be expanded to other backends too; I started with Windows
because the implementation is the both the easiest and has the least
amount of control (just setting a boolean parameter), and we can focus
mostly on writing tests and documentation and the for it, and we can
then match the inotify and kqueue behaviour to the Windows one.