2021-10-05 08:55:12 +00:00
|
|
|
# Message
|
2021-06-22 11:52:46 +00:00
|
|
|
|
|
|
|
You can think of xplr as a server. Just like web servers listen to HTTP
|
2023-07-13 13:12:21 +00:00
|
|
|
requests, xplr listens to messages.
|
|
|
|
|
|
|
|
A message is a [sum type][9] that can have [these possible values][1].
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2021-07-02 15:22:51 +00:00
|
|
|
You can send these messages to an xplr session in the following ways:
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2022-02-19 11:26:45 +00:00
|
|
|
- Via command-line (currently during start-up only, using `--on-load`)
|
2021-07-03 09:24:37 +00:00
|
|
|
- Via [key bindings][2]
|
|
|
|
- Via [Lua function calls][3]
|
|
|
|
- Via shell command using the [input pipe][4]
|
2022-02-19 11:26:45 +00:00
|
|
|
- Via socket (coming soon)
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2022-02-27 13:16:53 +00:00
|
|
|
### Format
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2023-05-22 04:20:42 +00:00
|
|
|
To send messages using the [key bindings][2] or [Lua function calls][3],
|
|
|
|
messages are represented in [Lua][5] syntax.
|
|
|
|
|
|
|
|
For example:
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2022-05-16 11:54:32 +00:00
|
|
|
- `"Quit"`
|
|
|
|
- `{ FocusPath = "/path/to/file" }`
|
|
|
|
- `{ Call = { command = "bash", args = { "-c", "read -p test" } } }`
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2021-07-03 09:24:37 +00:00
|
|
|
However, to send messages using the [input pipe][4], they need to be
|
2023-05-22 04:20:42 +00:00
|
|
|
represented using [YAML][6] (or [JSON][7]) syntax.
|
|
|
|
|
|
|
|
For example:
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2022-05-16 11:54:32 +00:00
|
|
|
- `Quit`
|
|
|
|
- `FocusPath: "/path/to/file"`
|
|
|
|
- `Call: { command: bash, args: ["-c", "read -p test"] }`
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2023-05-22 04:20:42 +00:00
|
|
|
Use `"$XPLR" -m TEMPLATE [VALUE]...` command-line option to safely format
|
|
|
|
`TEMPLATE` into a valid message. If uses [jf][8] to parse and render the
|
|
|
|
template. And `$XPLR` (rather than `xplr`) makes sure that the correct version
|
|
|
|
of the binary is being used.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
- `"$XPLR" -m Quit`
|
|
|
|
- `"$XPLR" -m 'FocusPath: %q' "/path/to/file"`
|
|
|
|
- `"$XPLR" -m 'Call: { command: %q, args: [%*q] }' bash -c "read -p test"`
|
|
|
|
|
2022-02-27 13:16:53 +00:00
|
|
|
## Also See:
|
2021-07-02 15:22:51 +00:00
|
|
|
|
2022-02-27 13:16:53 +00:00
|
|
|
- [Full List of Messages][1]
|
2021-07-02 15:22:51 +00:00
|
|
|
|
2022-02-27 13:16:53 +00:00
|
|
|
[1]: messages.md
|
2021-11-05 07:36:13 +00:00
|
|
|
[2]: key-bindings.md
|
2022-02-27 08:40:17 +00:00
|
|
|
[3]: lua-function-calls.md
|
|
|
|
[4]: environment-variables-and-pipes.md#input-pipe
|
2021-10-05 08:55:12 +00:00
|
|
|
[5]: https://www.lua.org/
|
|
|
|
[6]: http://yaml.org/
|
|
|
|
[7]: https://www.json.org
|
2023-05-22 04:20:42 +00:00
|
|
|
[8]: https://github.com/sayanarijit/jf
|
2023-07-13 13:12:21 +00:00
|
|
|
[9]: sum-type.md
|