mod extract;
mod protocol;
use std::io::{self, BufRead, Write};
fn main() {
let stdin = io::stdin();
let mut stdout = io::stdout();
for line in stdin.lock().lines() {
let line = match line {
Ok(l) => l,
Err(e) => {
eprintln!("stdin read error: {e}");
break;
},
};
let trimmed = line.trim();
if trimmed.is_empty() {
continue;
}
if let Some(response) = protocol::handle_message(trimmed) {
let _ = writeln!(stdout, "{response}");
let _ = stdout.flush();
}
}
}