comments
This commit is contained in:
parent
7c6efb4755
commit
41524a18af
3 changed files with 23 additions and 1 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue