Add binary to fetch fen from game
It can be used to show the game in external programs.
This commit is contained in:
parent
4748d61bca
commit
8377717cc3
20
src/bin/fetch_game_info.rs
Normal file
20
src/bin/fetch_game_info.rs
Normal file
@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user