tas/src/cli/pause.rs

25 lines
686 B
Rust

use crate::cli::print_task_detail;
use crate::repo::{self, Repository};
pub fn execute(repo: impl Repository) {
let task = match repo.stop_task() {
Err(repo::Error::NotFound) => {
return eprintln!("You can use the pause subcommand only when you have an active task")
}
Err(err) => {
return eprintln!("Cannot read current task: {}", err);
}
Ok(task) => task,
};
match repo.stop_task() {
Ok(_) => {
println!("The task was paused successfully");
print_task_detail(&task);
}
Err(err) => {
eprintln!("Cannot pause the task: {}", err);
}
}
}