2022-08-05 18:25:01 +03:00
|
|
|
use std::io::Write;
|
2022-08-05 17:58:54 +03:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
use crate::CurrentTaskInfo;
|
|
|
|
|
|
|
|
pub struct Request {
|
|
|
|
pub current_task_info: Option<CurrentTaskInfo>,
|
|
|
|
pub current_task_info_file_path: PathBuf,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn execute(mut req: Request) {
|
|
|
|
if req.current_task_info.take().is_none() {
|
|
|
|
panic!("You can use the pause subcommand only when you have an active task");
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut file = std::fs::File::create(&req.current_task_info_file_path).unwrap();
|
|
|
|
file.write_all(&serde_json::to_vec(&req.current_task_info).unwrap())
|
|
|
|
.unwrap();
|
|
|
|
println!("paused");
|
|
|
|
}
|