This commit is contained in:
JMARyA 2024-06-07 09:22:08 +02:00
parent 7c6efb4755
commit 41524a18af
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
3 changed files with 23 additions and 1 deletions

View file

@ -355,4 +355,14 @@ impl VikunjaAPI {
let resp = self.get_request(&format!("/tasks/{task_id}/comments"));
serde_json::from_str(&resp).unwrap()
}
pub fn new_comment(&self, task_id: isize, comment: &str) -> Comment {
let resp = self.put_request(
&format!("/tasks/{task_id}/comments"),
&serde_json::json!({
"comment": comment
}),
);
serde_json::from_str(&resp).unwrap()
}
}

View file

@ -74,6 +74,13 @@ pub fn get_args() -> clap::ArgMatches {
.about("Show task comments")
.arg(arg!([task_id] "Task ID").required(true)),
)
.subcommand(
command!()
.name("comment")
.about("Comment on a task")
.arg(arg!([task_id] "Task ID").required(true))
.arg(arg!([comment] "Comment").required(true)),
)
.subcommand(
command!()
.name("fav")

View file

@ -7,7 +7,6 @@ use api::{ProjectID, VikunjaAPI};
// todo : error handling
// todo : task relations
// todo : task comments
fn main() {
let arg = args::get_args();
@ -98,6 +97,12 @@ fn main() {
ui::task::print_comment(&comment);
}
}
Some(("comment", comment_arg)) => {
let task_id: &String = comment_arg.get_one("task_id").unwrap();
let comment: &String = comment_arg.get_one("comment").unwrap();
api.new_comment(task_id.parse().unwrap(), comment);
}
Some(("labels", label_args)) => match label_args.subcommand() {
Some(("rm", rm_label_arg)) => {
let title: &String = rm_label_arg.get_one("title").unwrap();