aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorache <ache@ache.one>2026-08-09 19:26:06 +0200
committerache <ache@ache.one>2026-08-09 19:26:06 +0200
commit43a24ce48fbd226fb8957900cd5af5cbea08c284 (patch)
tree997d1c401b772f94479b159c6e8546ed7f0d64d8 /src/main.rs
parentAdd function to pprint the legende (diff)
Pretty print the legende fixed
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 13 insertions, 8 deletions
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<State>, target: &IpAddr, tx: &mpsc::Sender<PingResult>, rx: &mut mpsc::Receiver<PingResult>, packet_id: &mut u32) {
-
+fn main_loop(
+ args: &Args,
+ states: &mut Vec<State>,
+ target: &IpAddr,
+ tx: &mpsc::Sender<PingResult>,
+ rx: &mut mpsc::Receiver<PingResult>,
+ 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<State>, 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;
- }
+ },
}
}