add task rm

This commit is contained in:
JMARyA 2024-06-06 16:11:20 +02:00
parent 78452bdb15
commit 91b86000ef
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
3 changed files with 14 additions and 0 deletions

View file

@ -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;

View file

@ -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()
}

View file

@ -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();