feat(nextcloud): add command 'nextcloud card get'
Some checks failed
Test / build (map[name:nightly]) (push) Successful in 1m51s
Test / build (map[name:stable]) (push) Successful in 2m20s
Release Please / Release-plz (push) Failing after 18s

This commit is contained in:
Paul Campbell 2024-12-07 09:56:40 +00:00
parent 76abea2fb0
commit ecef639318
4 changed files with 98 additions and 2 deletions

View file

@ -74,6 +74,12 @@ enum NextcloudCardCommand {
dump: bool, dump: bool,
stack_id: i64, stack_id: i64,
}, },
Get {
#[clap(long, action = clap::ArgAction::SetTrue)]
dump: bool,
stack_id: i64,
card_id: i64,
},
} }
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@ -157,6 +163,11 @@ pub async fn run(ctx: Ctx) -> color_eyre::Result<()> {
dump, dump,
stack_id, stack_id,
})) => nextcloud::card::list(ctx, dump, stack_id.into()).await, })) => nextcloud::card::list(ctx, dump, stack_id.into()).await,
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
dump,
stack_id,
card_id,
})) => nextcloud::card::get(ctx, dump, stack_id.into(), card_id.into()).await,
} }
} }
} }

View file

@ -1,6 +1,8 @@
// //
use crate::nextcloud::model::NextcloudStackId; use crate::{
use crate::{p, FullCtx}; nextcloud::model::{NextcloudCardId, NextcloudStackId},
p, FullCtx,
};
pub(crate) async fn list( pub(crate) async fn list(
ctx: FullCtx, ctx: FullCtx,
@ -22,3 +24,22 @@ pub(crate) async fn list(
} }
Ok(()) Ok(())
} }
pub(crate) async fn get(
ctx: FullCtx,
dump: bool,
stack_id: NextcloudStackId,
card_id: NextcloudCardId,
) -> color_eyre::Result<()> {
let api_result = ctx
.deck_client()
.get_card(ctx.cfg.nextcloud.board_id, stack_id, card_id)
.await;
if dump {
p!(ctx.prt, "{}", api_result.text);
} else {
let card = api_result.result?;
p!(ctx.prt, "{}:{}", card.id, card.title);
}
Ok(())
}

View file

@ -140,4 +140,17 @@ impl<'ctx> DeckClient<'ctx> {
) )
.await .await
} }
async fn get_card(
&self,
board_id: NextcloudBoardId,
stack_id: NextcloudStackId,
card_id: model::NextcloudCardId,
) -> APIResult<Card> {
self.request(
f!("boards/{board_id}/stacks/{stack_id}/cards/{card_id}"),
|net, url| net.get(url),
)
.await
}
} }

View file

@ -0,0 +1,51 @@
{
"id": 321,
"title": "Breakfast: Cereal",
"description": "",
"stackId": 1,
"type": "plain",
"lastModified": 1733515897,
"lastEditor": null,
"createdAt": 1733043461,
"labels": [
{
"id": 1,
"title": "Finished",
"color": "31CC7C",
"boardId": 1,
"cardId": 321,
"lastModified": 1670965629,
"ETag": "983f87848dc9c18d0aee63e7ee0fc83f"
}
],
"assignedUsers": [
{
"id": 24,
"participant": {
"primaryKey": "pcampbell",
"uid": "pcampbell",
"displayname": "Paul Campbell",
"type": 0
},
"cardId": 321,
"type": 0
}
],
"attachments": [],
"attachmentCount": 0,
"owner": {
"primaryKey": "pcampbell",
"uid": "pcampbell",
"displayname": "Paul Campbell",
"type": 0
},
"order": 1,
"archived": false,
"done": null,
"duedate": null,
"deletedAt": 0,
"commentsUnread": 0,
"commentsCount": 0,
"ETag": "bf59162abcbc193b94349985122d7009",
"overdue": 0
}