25 lines
470 B
Rust
25 lines
470 B
Rust
use std::{io, sync::Arc};
|
|
|
|
use crate::server;
|
|
|
|
pub fn handle_stdin(server: Arc<server::ServerProcess>) {
|
|
let stdin = io::stdin();
|
|
let input = &mut String::new();
|
|
|
|
loop {
|
|
input.clear();
|
|
|
|
if stdin.read_line(input).is_err() {
|
|
continue;
|
|
};
|
|
|
|
if let Err(e) = server.send_command(input) {
|
|
println!("{}", e);
|
|
};
|
|
|
|
if input.trim() == "stop" {
|
|
std::process::exit(0);
|
|
}
|
|
}
|
|
}
|