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