feat: all output lines in table format incl. connecting/session rows
This commit is contained in:
parent
959a00ff8a
commit
72f19af12b
1 changed files with 10 additions and 12 deletions
|
|
@ -196,7 +196,7 @@ async fn main() {
|
|||
.next()
|
||||
.unwrap_or(&config.relay_url);
|
||||
|
||||
display::status("🌐", &format!("Connecting to {}...", host));
|
||||
display::cmd_start("🌐", "connecting", host);
|
||||
|
||||
let tls_connector = TlsConnector::builder()
|
||||
.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 {
|
||||
Ok((ws_stream, _)) => {
|
||||
let label = config.label.clone().unwrap_or_else(|| hostname());
|
||||
display::ok("✅", &format!(
|
||||
"Connected {} {} {} Session {}",
|
||||
"·".dimmed(),
|
||||
label.bold(),
|
||||
"·".dimmed(),
|
||||
sid.to_string().dimmed()
|
||||
));
|
||||
display::cmd_done("🌐", "connecting", host, true, "connected");
|
||||
display::cmd_start("ℹ", "session", &label);
|
||||
display::cmd_done("ℹ", "session", &label, true, &sid.to_string());
|
||||
println!();
|
||||
backoff = Duration::from_secs(1);
|
||||
|
||||
|
|
@ -225,7 +221,7 @@ async fn main() {
|
|||
};
|
||||
let hello_json = serde_json::to_string(&hello).unwrap();
|
||||
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;
|
||||
backoff = (backoff * 2).min(MAX_BACKOFF);
|
||||
continue;
|
||||
|
|
@ -270,11 +266,12 @@ async fn main() {
|
|||
let _ = w.send(Message::Pong(data)).await;
|
||||
}
|
||||
Ok(Message::Close(_)) => {
|
||||
display::err("❌", "Connection lost — reconnecting...");
|
||||
display::cmd_start("🌐", "connecting", host);
|
||||
display::cmd_done("🌐", "connecting", host, false, "connection lost");
|
||||
break;
|
||||
}
|
||||
Err(e) => {
|
||||
display::err("❌", &format!("Connection lost: {e} — reconnecting..."));
|
||||
display::cmd_done("🌐", "connecting", host, false, &format!("lost: {e}"));
|
||||
break;
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -282,7 +279,8 @@ async fn main() {
|
|||
}
|
||||
}
|
||||
Err(e) => {
|
||||
display::err("❌", &format!("Connection failed: {e}"));
|
||||
display::cmd_start("🌐", "connecting", host);
|
||||
display::cmd_done("🌐", "connecting", host, false, &format!("{e}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue