2024-12-09 22:18:40 +00:00
|
|
|
//
|
|
|
|
use clap::Parser;
|
|
|
|
use color_eyre::Result;
|
|
|
|
|
|
|
|
use crate::{execute::Execute, p, FullCtx};
|
|
|
|
|
|
|
|
use super::model::TrelloCardId;
|
|
|
|
|
|
|
|
#[derive(Parser, Debug)]
|
2024-12-15 20:07:34 +00:00
|
|
|
pub enum TrelloCardCommand {
|
2024-12-09 22:18:40 +00:00
|
|
|
Get {
|
|
|
|
#[clap(long, action = clap::ArgAction::SetTrue)]
|
|
|
|
dump: bool,
|
|
|
|
|
|
|
|
card_id: String,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Execute for TrelloCardCommand {
|
2024-12-15 20:07:34 +00:00
|
|
|
async fn execute(&self, ctx: &FullCtx) -> Result<()> {
|
2024-12-09 22:18:40 +00:00
|
|
|
match self {
|
|
|
|
Self::Get { dump, card_id } => {
|
|
|
|
let api_result = ctx.trello_client().card(&TrelloCardId::new(card_id)).await;
|
2024-12-15 20:07:34 +00:00
|
|
|
if *dump {
|
2024-12-09 22:18:40 +00:00
|
|
|
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(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|