use std::io::Read;
use std::thread;
pub(super) fn ready_line(port: u16) -> String {
let payload = serde_json::json!({ "url": format!("http://localhost:{port}/"), "port": port });
format!("FUSIBLE_READY {payload}")
}
pub(super) fn announce_ready(port: u16) {
println!("{}", ready_line(port));
}
pub(super) fn wait_for_eof(mut reader: impl Read) {
let mut sink = [0u8; 256];
while matches!(reader.read(&mut sink), Ok(read) if read > 0) {}
}
pub(super) fn exit_on_stdin_eof() {
thread::spawn(|| {
wait_for_eof(std::io::stdin());
std::process::exit(0);
});
}