2022-08-16 15:43:44 +03:00
|
|
|
use crate::repo::{self, Repository};
|
2022-08-05 17:58:54 +03:00
|
|
|
|
2022-08-16 15:43:44 +03:00
|
|
|
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,
|
|
|
|
};
|
2022-08-05 17:58:54 +03:00
|
|
|
|
2022-08-16 15:43:44 +03:00
|
|
|
match repo.stop_task() {
|
|
|
|
Ok(_) => {
|
|
|
|
println!("The task was paused successfully");
|
|
|
|
println!(" {}", task.name);
|
|
|
|
if let Some(link) = task.link {
|
|
|
|
println!(" link: {}", link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(err) => {
|
|
|
|
eprintln!("Cannot pause the task: {}", err);
|
|
|
|
}
|
2022-08-05 17:58:54 +03:00
|
|
|
}
|
|
|
|
}
|