commit
528dd36455
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "odilia-control"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
@ -0,0 +1,15 @@
|
|||||||
|
# odilia-control
|
||||||
|
|
||||||
|
Test for JSON-RPC based communication.
|
||||||
|
|
||||||
|
Here are some examples on how to use it once odilia-recv (other test program_ is running.
|
||||||
|
|
||||||
|
Try the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
odilia-control '{"jsonrpc": "2.0", "method": "test", "id": "123"}'
|
||||||
|
odilia-control '{"jsonrpc": "2.0", "method": "next", "params": [{"tag": "code", "role": "link"}], "id": "123"}'
|
||||||
|
```
|
||||||
|
|
||||||
|
This program doesn't fascilitate a return yet, because it's just a proof of concept.
|
||||||
|
More ronbustness to come.
|
@ -0,0 +1,24 @@
|
|||||||
|
use std::{
|
||||||
|
os::unix::net::UnixStream,
|
||||||
|
process::exit,
|
||||||
|
io::Write,
|
||||||
|
env,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn sock_send(command: &str) -> std::io::Result<()> {
|
||||||
|
let mut stream = UnixStream::connect("/tmp/odilia-ctrl.sock")?;
|
||||||
|
stream.write_all(command.as_bytes())?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut args_vec: Vec<String> = env::args().collect();
|
||||||
|
args_vec.remove(0);
|
||||||
|
let args = args_vec.join(" ");
|
||||||
|
if args.len() == 0 {
|
||||||
|
println!("You cannot send an empty command");
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
let _ = sock_send(&args);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue