diff --git a/socktop/src/app.rs b/socktop/src/app.rs index 46707e6..d2fe40d 100644 --- a/socktop/src/app.rs +++ b/socktop/src/app.rs @@ -101,8 +101,12 @@ impl App { } pub fn with_intervals(mut self, metrics_ms: Option, procs_ms: Option) -> Self { - if let Some(m) = metrics_ms { self.metrics_interval = Duration::from_millis(m.max(100)); } - if let Some(p) = procs_ms { self.procs_interval = Duration::from_millis(p.max(200)); } + if let Some(m) = metrics_ms { + self.metrics_interval = Duration::from_millis(m.max(100)); + } + if let Some(p) = procs_ms { + self.procs_interval = Duration::from_millis(p.max(200)); + } self } diff --git a/socktop/src/main.rs b/socktop/src/main.rs index 62b07ca..1779626 100644 --- a/socktop/src/main.rs +++ b/socktop/src/main.rs @@ -55,8 +55,12 @@ pub(crate) fn parse_args>(args: I) -> Result { metrics_interval_ms = it.next().and_then(|v| v.parse().ok()); } - "--processes-interval-ms" => { processes_interval_ms = it.next().and_then(|v| v.parse().ok()); } + "--metrics-interval-ms" => { + metrics_interval_ms = it.next().and_then(|v| v.parse().ok()); + } + "--processes-interval-ms" => { + processes_interval_ms = it.next().and_then(|v| v.parse().ok()); + } _ if arg.starts_with("--tls-ca=") => { if let Some((_, v)) = arg.split_once('=') { if !v.is_empty() { @@ -71,8 +75,16 @@ pub(crate) fn parse_args>(args: I) -> Result io::Result { Ok(line) } -fn gather_intervals(arg_metrics: Option, arg_procs: Option) -> Result<(Option, Option), Box> { +fn gather_intervals( + arg_metrics: Option, + arg_procs: Option, +) -> Result<(Option, Option), Box> { let default_metrics = 500u64; let default_procs = 2000u64; let metrics = match arg_metrics { Some(v) => Some(v), None => { - let inp = prompt_string(&format!("Metrics interval ms (default {default_metrics}, Enter for default): "))?; + let inp = prompt_string(&format!( + "Metrics interval ms (default {default_metrics}, Enter for default): " + ))?; let t = inp.trim(); - if t.is_empty() { Some(default_metrics) } else { Some(t.parse()?) } + if t.is_empty() { + Some(default_metrics) + } else { + Some(t.parse()?) + } } }; let procs = match arg_procs { Some(v) => Some(v), None => { - let inp = prompt_string(&format!("Processes interval ms (default {default_procs}, Enter for default): "))?; + let inp = prompt_string(&format!( + "Processes interval ms (default {default_procs}, Enter for default): " + ))?; let t = inp.trim(); - if t.is_empty() { Some(default_procs) } else { Some(t.parse()?) } + if t.is_empty() { + Some(default_procs) + } else { + Some(t.parse()?) + } } }; Ok((metrics, procs))