add fav
This commit is contained in:
parent
d038923726
commit
8c6310eb61
3 changed files with 24 additions and 0 deletions
|
@ -298,6 +298,16 @@ impl VikunjaAPI {
|
|||
serde_json::from_str(&resp).unwrap()
|
||||
}
|
||||
|
||||
pub fn fav_task(&self, task_id: isize, fav: bool) -> Task {
|
||||
let resp = self.post_request(
|
||||
&format!("/tasks/{task_id}"),
|
||||
&serde_json::json!({
|
||||
"is_favorite": fav
|
||||
}),
|
||||
);
|
||||
serde_json::from_str(&resp).unwrap()
|
||||
}
|
||||
|
||||
pub fn login(&self, username: &str, password: &str, totp: Option<&str>) -> String {
|
||||
let resp = self.post_request(
|
||||
"/login",
|
||||
|
|
|
@ -68,6 +68,13 @@ pub fn get_args() -> clap::ArgMatches {
|
|||
.arg(arg!([user] "User").required(true))
|
||||
.arg(arg!([task_id] "Task ID").required(true)),
|
||||
)
|
||||
.subcommand(
|
||||
command!()
|
||||
.name("fav")
|
||||
.about("Favorite a task")
|
||||
.arg(arg!(-u --undo "Remove favorite from task").required(false))
|
||||
.arg(arg!([task_id] "Task ID").required(true)),
|
||||
)
|
||||
.subcommand(
|
||||
command!()
|
||||
.name("label")
|
||||
|
|
|
@ -132,6 +132,13 @@ fn main() {
|
|||
api.done_task(task_id.parse().unwrap(), done);
|
||||
ui::task::print_task_info(task_id.parse().unwrap(), &api);
|
||||
}
|
||||
Some(("fav", fav_args)) => {
|
||||
let task_id: &String = fav_args.get_one("task_id").unwrap();
|
||||
let undo = fav_args.get_flag("undo");
|
||||
|
||||
api.fav_task(task_id.parse().unwrap(), !undo);
|
||||
ui::task::print_task_info(task_id.parse().unwrap(), &api);
|
||||
}
|
||||
_ => {
|
||||
let done = arg.get_flag("done");
|
||||
let fav = arg.get_flag("favorite");
|
||||
|
|
Loading…
Reference in a new issue