alex/src/stdin.rs

25 lines
470 B
Rust
Raw Normal View History

use std::{io, sync::Arc};
2023-06-06 16:57:59 +02:00
use crate::server;
pub fn handle_stdin(server: Arc<server::ServerProcess>) {
2023-06-06 16:57:59 +02:00
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);
};
2023-06-06 16:57:59 +02:00
if input.trim() == "stop" {
std::process::exit(0);
}
}
}