fix(main): improve feedback for (( command

This commit is contained in:
xeruf 2024-11-11 01:08:05 +01:00
parent 5dbea00562
commit d1735476cc
2 changed files with 18 additions and 8 deletions

View file

@ -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;
if remaining.len() > 0 {
match remaining.parse::<usize>() {
Ok(number) => max = number,
Err(e) => warn!("Unsure what to do with {:?}", e),
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);

View file

@ -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)| {