diff --git a/src/api/mod.rs b/src/api/mod.rs index 3651714..b352ef9 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -259,6 +259,10 @@ impl VikunjaAPI { serde_json::from_str(&resp).unwrap() } + pub fn delete_task(&self, id: isize) { + self.delete_request(&format!("/tasks/{id}")); + } + pub fn new_task(&self, title: &str, project: &ProjectID) -> Task { let id = project.0; diff --git a/src/args.rs b/src/args.rs index 7f84d79..8ff7159 100644 --- a/src/args.rs +++ b/src/args.rs @@ -106,5 +106,11 @@ pub fn get_args() -> clap::ArgMatches { .about("Mark task as done") .arg(arg!([task_id] "Task ID").required(true)), ) + .subcommand( + command!() + .name("rm") + .about("Remove task") + .arg(arg!([task_id] "Task ID").required(true)), + ) .get_matches() } diff --git a/src/main.rs b/src/main.rs index 702558e..5114097 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,6 +48,10 @@ fn main() { ui::project::list_projects(&api); } }, + Some(("rm", rm_args)) => { + let task_id: &String = rm_args.get_one("task_id").unwrap(); + api.delete_task(task_id.parse().unwrap()); + } Some(("assign", assign_arg)) => { let user: &String = assign_arg.get_one("user").unwrap(); let task_id: &String = assign_arg.get_one("task_id").unwrap();