feat: all output lines in table format incl. connecting/session rows

This commit is contained in:
Helios Agent 2026-03-05 19:59:18 +01:00
parent 959a00ff8a
commit 72f19af12b
No known key found for this signature in database
GPG key ID: C8259547CD8309B5

View file

@ -196,7 +196,7 @@ async fn main() {
.next() .next()
.unwrap_or(&config.relay_url); .unwrap_or(&config.relay_url);
display::status("🌐", &format!("Connecting to {}...", host)); display::cmd_start("🌐", "connecting", host);
let tls_connector = TlsConnector::builder() let tls_connector = TlsConnector::builder()
.danger_accept_invalid_certs(true) .danger_accept_invalid_certs(true)
@ -207,13 +207,9 @@ async fn main() {
match connect_async_tls_with_config(&config.relay_url, None, false, Some(connector)).await { match connect_async_tls_with_config(&config.relay_url, None, false, Some(connector)).await {
Ok((ws_stream, _)) => { Ok((ws_stream, _)) => {
let label = config.label.clone().unwrap_or_else(|| hostname()); let label = config.label.clone().unwrap_or_else(|| hostname());
display::ok("", &format!( display::cmd_done("🌐", "connecting", host, true, "connected");
"Connected {} {} {} Session {}", display::cmd_start("", "session", &label);
"·".dimmed(), display::cmd_done("", "session", &label, true, &sid.to_string());
label.bold(),
"·".dimmed(),
sid.to_string().dimmed()
));
println!(); println!();
backoff = Duration::from_secs(1); backoff = Duration::from_secs(1);
@ -225,7 +221,7 @@ async fn main() {
}; };
let hello_json = serde_json::to_string(&hello).unwrap(); let hello_json = serde_json::to_string(&hello).unwrap();
if let Err(e) = write.send(Message::Text(hello_json)).await { if let Err(e) = write.send(Message::Text(hello_json)).await {
display::err("", &format!("Failed to send Hello: {e}")); display::err("", &format!("hello failed: {e}"));
tokio::time::sleep(backoff).await; tokio::time::sleep(backoff).await;
backoff = (backoff * 2).min(MAX_BACKOFF); backoff = (backoff * 2).min(MAX_BACKOFF);
continue; continue;
@ -270,11 +266,12 @@ async fn main() {
let _ = w.send(Message::Pong(data)).await; let _ = w.send(Message::Pong(data)).await;
} }
Ok(Message::Close(_)) => { Ok(Message::Close(_)) => {
display::err("", "Connection lost — reconnecting..."); display::cmd_start("🌐", "connecting", host);
display::cmd_done("🌐", "connecting", host, false, "connection lost");
break; break;
} }
Err(e) => { Err(e) => {
display::err("", &format!("Connection lost: {e} — reconnecting...")); display::cmd_done("🌐", "connecting", host, false, &format!("lost: {e}"));
break; break;
} }
_ => {} _ => {}
@ -282,7 +279,8 @@ async fn main() {
} }
} }
Err(e) => { Err(e) => {
display::err("", &format!("Connection failed: {e}")); display::cmd_start("🌐", "connecting", host);
display::cmd_done("🌐", "connecting", host, false, &format!("{e}"));
} }
} }