However, with -j -p, only one command is accepted from stdin. It is not possible to pass both the watch and the subscribe on stdin without restarting watchman:
$ watchman --no-pretty -j -p
["watch","."]
{"version":"20220924.070135.0","watcher":"inotify","watch":"/path/to/working/directory"}
["subscribe",".","name",{"expression":["type","f"]}]
(no response)
I have an application that needs to watch for changes in multiple roots, so I would like to run watchman and pass it several watch and subscribe commands. This sort of thing is possible with the socket interface, but in the language that I am working with there is no unified interface to Unix sockets and Windows named pipes, while there is a unified interface to subprocesses. Therefore it would be very easy if watchman -j -p would accept more than one command.
Am I right in thinking this is currently not possible with a single watchman subprocess?
Would it be possible to change this by moving the handling of the persistent flag from Command.cpp to main.cpp?
The
watchman
executable with-j
/--json-command
accepts JSON commands from stdin, as in:When
-p
/--persistent
is used, the executable does not exit, which is useful for commands likesubscribe
:However, with
-j -p
, only one command is accepted from stdin. It is not possible to pass both thewatch
and thesubscribe
on stdin without restartingwatchman
:I have an application that needs to watch for changes in multiple roots, so I would like to run
watchman
and pass it severalwatch
andsubscribe
commands. This sort of thing is possible with the socket interface, but in the language that I am working with there is no unified interface to Unix sockets and Windows named pipes, while there is a unified interface to subprocesses. Therefore it would be very easy ifwatchman -j -p
would accept more than one command.watchman
subprocess?persistent
flag from Command.cpp to main.cpp?