Only show last message

This stops intermediate commands from showing things like auth
succeeding every time
This commit is contained in:
2026-05-30 22:19:56 -07:00
parent b1f31a0de8
commit 6024798053
+15 -3
View File
@@ -90,6 +90,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
debug!("Sending commands"); debug!("Sending commands");
let mut response: fedichat::client::ServerMessage = ServerMessage::Ok;
for message in messages { for message in messages {
let mut buf = Vec::new(); let mut buf = Vec::new();
@@ -104,7 +106,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Max response should never be this big but we can spare the memory // Max response should never be this big but we can spare the memory
let received = recv.read_to_end(1000 * 1000).await?; let received = recv.read_to_end(1000 * 1000).await?;
let response: fedichat::client::ServerMessage = rmp_serde::from_slice(&received)?; response = rmp_serde::from_slice(&received)?;
// If we received a message that gave us a new token then update the local copy // If we received a message that gave us a new token then update the local copy
match response { match response {
ServerMessage::Token(ref token) => { ServerMessage::Token(ref token) => {
@@ -114,12 +116,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut file = File::create(file_to_write.clone().expect("File path not specified"))?; let mut file = File::create(file_to_write.clone().expect("File path not specified"))?;
file.write_all(bytes)?; file.write_all(bytes)?;
}, },
ServerMessage::Error(_) => {
break;
},
_ => {} _ => {}
} }
println!("{:?}",response);
} }
println!("{}",format_response(response));
// On listen specifically we will stay connected // On listen specifically we will stay connected
@@ -128,6 +133,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
}
fn format_response(m: ServerMessage) -> String {
match m {
ServerMessage::Media(_) => "File received".to_string(),
m => format!("{:?}",m)
}
} }