From a0c46b6ea1d6c7655c0c60d1c50761c1e987017d Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 18 Jul 2024 00:38:27 +0300 Subject: [PATCH] Display nested tasks in prompt --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 872b008..4aef894 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,7 +92,15 @@ async fn repl() { let mut tasks: HashMap = HashMap::new(); let mut position: Option = None; loop { - print!(" {}> ", position.map_or(String::from(""), |id| tasks.get(&id).map_or(id.to_string(), |t| t.event.content.clone()))); + let mut prompt = String::from(""); + let mut pos = position; + while pos.is_some() { + let id = pos.unwrap(); + let task = tasks.get(&id); + prompt = task.map_or(id.to_string(), |t| t.event.content.clone()) + " " + &prompt; + pos = task.and_then(|t| t.parent_id()); + } + print!(" {}> ", prompt); stdout().flush().unwrap(); match stdin().lines().next() { Some(Ok(input)) => {