forked from janek/mostr
Display nested tasks in prompt
This commit is contained in:
parent
660f9a248c
commit
a0c46b6ea1
10
src/main.rs
10
src/main.rs
|
@ -92,7 +92,15 @@ async fn repl() {
|
||||||
let mut tasks: HashMap<EventId, Task> = HashMap::new();
|
let mut tasks: HashMap<EventId, Task> = HashMap::new();
|
||||||
let mut position: Option<EventId> = None;
|
let mut position: Option<EventId> = None;
|
||||||
loop {
|
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();
|
stdout().flush().unwrap();
|
||||||
match stdin().lines().next() {
|
match stdin().lines().next() {
|
||||||
Some(Ok(input)) => {
|
Some(Ok(input)) => {
|
||||||
|
|
Loading…
Reference in New Issue