21 lines
841 B
Rust
21 lines
841 B
Rust
use clichess::ClientRequest;
|
|
use std::os::unix::net::UnixStream;
|
|
|
|
|
|
fn main() {
|
|
let version = env!("CARGO_PKG_VERSION");
|
|
eprintln!("Running clichess fetch_game_info version {}", version);
|
|
let mut stream = match UnixStream::connect("/tmp/clichess.socket") {
|
|
Ok(sock) => sock,
|
|
Err(_) => {
|
|
eprintln!("clichess daemon is not running.");
|
|
return;
|
|
}
|
|
};
|
|
clichess::write_to_stream(&mut stream, serde_json::to_string(&ClientRequest::GetGameInfo).unwrap()).unwrap();
|
|
let response = clichess::read_line_from_stream(&stream).expect("Error message from server");
|
|
clichess::write_to_stream(&mut stream, serde_json::to_string(&ClientRequest::Exit).unwrap()).unwrap();
|
|
clichess::read_line_from_stream(&stream).expect("Error message from server");
|
|
println!("{}", response);
|
|
}
|