tas/src/cli/list.rs

24 lines
561 B
Rust
Raw Normal View History

2022-08-05 18:25:01 +03:00
use crate::{CurrentTaskInfo, Task};
pub struct Request {
pub tasks: Vec<Task>,
pub current_task_info: Option<CurrentTaskInfo>,
}
pub fn execute(req: Request) {
for (i, task) in req.tasks.iter().enumerate() {
let idx = i + 1;
match req.current_task_info {
Some(CurrentTaskInfo { task_idx, .. }) if task_idx == idx => print!("> "),
_ => print!(" "),
}
print!("{}. ", idx);
if task.link.is_some() {
print!("(link) ");
}
println!("{}", task.name);
}
}