trello-to-deck/src/trello/card.rs

37 lines
966 B
Rust
Raw Normal View History

//
use clap::Parser;
use color_eyre::Result;
use crate::{execute::Execute, p, FullCtx};
use super::model::TrelloCardId;
#[derive(Parser, Debug)]
pub(crate) 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(())
}
}
}
}