trello-to-deck/src/trello/card.rs
Paul Campbell 336a5945a4
Some checks failed
Release Please / Release-plz (push) Failing after 15s
Test / build (map[name:stable]) (push) Waiting to run
Test / build (map[name:nightly]) (push) Has been cancelled
refactor(trello): rearrange model
2024-12-19 09:06:44 +00:00

36 lines
965 B
Rust

//
use clap::Parser;
use color_eyre::Result;
use crate::{execute::Execute, p, FullCtx};
use super::model::card::TrelloCardId;
#[derive(Parser, Debug)]
pub enum TrelloCardCommand {
Get {
#[clap(long, action = clap::ArgAction::SetTrue)]
dump: bool,
card_id: String,
},
}
impl Execute for TrelloCardCommand {
async fn execute(&self, ctx: &FullCtx) -> Result<()> {
match self {
Self::Get { dump, card_id } => {
let api_result = ctx.trello_client().card(&TrelloCardId::new(card_id)).await;
if *dump {
p!(ctx.prt, "{}", api_result.text);
} else {
let attachments = api_result.result?.attachments;
for attachment in attachments {
p!(ctx.prt, "{}:{}", attachment.id, attachment.name);
}
}
Ok(())
}
}
}
}