IPC: Accept multiple actions from stdin #1017
Open
+156
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This needs some testing,
io::stdin().lines()
behaves a little weird with EOF, notably pressing Ctrl + D twice (apparently that's a unix thing, you need to hit it twice when not at the start of a line), you still need to hit it an additional time for some reason.. withecho -e "one\ntwo" | niri msg action
it works as expected (by the way, it seems likeNIRI_SOCKET
isn't replaced correctly in the winit backend).I made the serialization prefer keeping 1-length vectors as single values to maximize compatibility. The amount of tests for
one_or_many
is a bit excessive (I thought a visitor was needed at first, and then got the order of the enum variants wrong, so they were helpful), should I only keep the derive ones?Also I'm not sure what should happen if you pass no actions, currently the cli prints a warning and does nothing but it's allowed in the ipc, should niri respond with an error instead?
Also, this currently splits on spaces, meaning it handles quoting and multiple spaces incorrectly, should this use e.g.
shlex
instead?