aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorache <ache@ache.one>2026-08-16 21:57:55 +0200
committerache <ache@ache.one>2026-08-16 21:57:55 +0200
commitf31f02f6bee6bf5d98d2d9468762cf6ea9d4360a (patch)
tree5effa2c2351f7f4901b52f7026dccab2f9c3fcad /src
parentRemove unusde import and cast (diff)
Add the remainder line option
Diffstat (limited to 'src')
-rw-r--r--src/main.rs12
-rw-r--r--src/print.rs6
2 files changed, 13 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index f35a052..00f6b49 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,7 +13,7 @@ mod stats;
use args::Args;
use ip::parse_ip;
use pinger::{PingResult, spawn_ping};
-use print::{print_legende_line, print_ping_line, print_stats};
+use print::{print_legende_line, print_ping_line, print_stats, print_remainder_line};
use state::State;
use stats::compute_stats;
@@ -131,10 +131,13 @@ fn main_loop(
async fn main() {
let args = Args::parse();
- let target: IpAddr = if let Some(target_str) = args.target.clone() {
+ let target_str: String;
+ let target: IpAddr = if let Some(target_arg) = args.target.clone() {
+ target_str = target_arg;
parse_target(&target_str)
} else if let Some(default_target_str) = args.default_target.clone() {
- parse_target(&default_target_str)
+ target_str = default_target_str;
+ parse_target(&target_str)
} else {
eprintln!("Error: target address is required");
std::process::exit(1);
@@ -150,8 +153,7 @@ async fn main() {
}
if args.remainder {
- // TODO: Not yet implemented
- // print_remainder_line
+ print_remainder_line(&target_str, &target);
}
// Save the current cursor position
diff --git a/src/print.rs b/src/print.rs
index 4019f34..f359c92 100644
--- a/src/print.rs
+++ b/src/print.rs
@@ -2,6 +2,7 @@
use crate::state::State;
use crate::stats::Stats;
+use std::net::IpAddr;
struct SymbolTableElement {
fg: &'static str,
@@ -180,6 +181,11 @@ const LEN_BY_NB_ELEMENT: [u32; 26] = [
16, 10, 4, 0,
];
+
+pub fn print_remainder_line(target_str: &String, ip: &IpAddr) {
+ println!("PING {} ({})", target_str, ip);
+}
+
pub fn print_legende_line() {
let nb_cols: u32 = if let Some((w, _)) = term_size::dimensions() {
w as u32