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()
|
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 {
|
pub fn login(&self, username: &str, password: &str, totp: Option<&str>) -> String {
|
||||||
let resp = self.post_request(
|
let resp = self.post_request(
|
||||||
"/login",
|
"/login",
|
||||||
|
|
|
@ -68,6 +68,13 @@ pub fn get_args() -> clap::ArgMatches {
|
||||||
.arg(arg!([user] "User").required(true))
|
.arg(arg!([user] "User").required(true))
|
||||||
.arg(arg!([task_id] "Task ID").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(
|
.subcommand(
|
||||||
command!()
|
command!()
|
||||||
.name("label")
|
.name("label")
|
||||||
|
|
|
@ -132,6 +132,13 @@ fn main() {
|
||||||
api.done_task(task_id.parse().unwrap(), done);
|
api.done_task(task_id.parse().unwrap(), done);
|
||||||
ui::task::print_task_info(task_id.parse().unwrap(), &api);
|
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 done = arg.get_flag("done");
|
||||||
let fav = arg.get_flag("favorite");
|
let fav = arg.get_flag("favorite");
|
||||||
|
|
Loading…
Reference in a new issue