From 43a24ce48fbd226fb8957900cd5af5cbea08c284 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 9 Aug 2026 19:26:06 +0200 Subject: Pretty print the legende fixed --- src/main.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 675634d..d7fae43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,14 @@ use print::{print_legende_line, print_ping_line, print_stats}; use state::State; use stats::compute_stats; -fn main_loop(args : &Args, states: &mut Vec, target: &IpAddr, tx: &mpsc::Sender, rx: &mut mpsc::Receiver, packet_id: &mut u32) { - +fn main_loop( + args: &Args, + states: &mut Vec, + target: &IpAddr, + tx: &mpsc::Sender, + rx: &mut mpsc::Receiver, + packet_id: &mut u32, +) { let current_time = State::current_time_ms(); for state in states.iter_mut() { if let State::NotYetReceived { time_sent } = state { @@ -70,9 +76,9 @@ fn main_loop(args : &Args, states: &mut Vec, target: &IpAddr, tx: &mpsc:: // Put the cursor back up if !std::process::Command::new("tput") .arg("rc") - .status() - .map(|s| s.success()) - .unwrap_or(false) + .status() + .map(|s| s.success()) + .unwrap_or(false) { println!("Process failed too"); std::process::exit(1); @@ -137,7 +143,6 @@ async fn main() { std::process::exit(1); } - let wait_time = args.interval.unwrap_or(1000); match args.count { Some(c) => { @@ -145,10 +150,10 @@ async fn main() { main_loop(&args, &mut states, &target, &tx, &mut rx, &mut packet_id); sleep(tokio::time::Duration::from_millis(wait_time as u64)).await; } - }, + } None => loop { main_loop(&args, &mut states, &target, &tx, &mut rx, &mut packet_id); sleep(tokio::time::Duration::from_millis(wait_time as u64)).await; - } + }, } } -- cgit v1.3-2-g11bf