From d1735476ccd2f6ff616e78c56dddee043fd99543 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 11 Nov 2024 01:08:05 +0100 Subject: [PATCH] fix(main): improve feedback for (( command --- src/main.rs | 24 +++++++++++++++++------- src/tasks.rs | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index c0aa067..794ae4c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -417,8 +417,8 @@ async fn main() -> Result<()> { } warn!("No connected relay contains {:?}", command); continue 'repl; - } - + } + let mut iter = arg_default.chars(); let next = iter.next(); let remaining = iter.collect::().trim().to_string(); @@ -552,7 +552,7 @@ async fn main() -> Result<()> { .inspect_err(|e| warn!("Invalid Priority {arg}: {e}")).ok() .map(|p: Prio| p * (if arg.len() < 2 { 10 } else { 1 }))); } - }, + } } } @@ -649,12 +649,22 @@ async fn main() -> Result<()> { let (first, remaining) = arg.split_at(1); if first == "(" { let mut max = usize::MAX; - match remaining.parse::() { - Ok(number) => max = number, - Err(e) => warn!("Unsure what to do with {:?}", e), + if remaining.len() > 0 { + match remaining.parse::() { + Ok(number) => max = number, + Err(e) => warn!("Ignoring extra {:?}: {}\nSyntax: ((INT", remaining, e), + } } let (label, times) = tasks.times_tracked(); - println!("{}\n{}", label.italic(), + let mut times = times.peekable(); + println!("{}\n{}", + if times.peek().is_some() { + format!("{} {}", + if max == usize::MAX { "All".to_string() } else { format!("Latest {max} entries of") }, + label) + } else { + label + }, times.rev().take(max).collect_vec().iter().rev().join("\n")); } else if let Ok(key) = PublicKey::parse(arg) { // TODO also match name let (label, mut times) = tasks.times_tracked_for(&key); diff --git a/src/tasks.rs b/src/tasks.rs index 0788f9a..1bd5f53 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -278,7 +278,7 @@ impl TasksRelay { } } Some(id) => { - // TODO consider pubkey + // TODO show current recursive with pubkey let ids = vec![id]; let history = self.history.iter().flat_map(|(key, set)| {