2024-12-09 13:40:55 +00:00
|
|
|
//
|
|
|
|
use clap::Parser;
|
|
|
|
|
|
|
|
use crate::execute::Execute;
|
|
|
|
use crate::{p, FullCtx};
|
|
|
|
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
pub(crate) enum TrelloMemberCommand {
|
|
|
|
Get {
|
|
|
|
#[clap(long, action = clap::ArgAction::SetTrue)]
|
|
|
|
dump: bool,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Execute for TrelloMemberCommand {
|
2024-12-15 20:07:34 +00:00
|
|
|
async fn execute(&self, ctx: &FullCtx) -> color_eyre::Result<()> {
|
2024-12-09 13:40:55 +00:00
|
|
|
match self {
|
|
|
|
Self::Get { dump } => {
|
2024-12-09 16:58:20 +00:00
|
|
|
let api_result = ctx.trello_client().boards().await;
|
2024-12-15 20:07:34 +00:00
|
|
|
if *dump {
|
2024-12-09 13:40:55 +00:00
|
|
|
p!(ctx.prt, "{}", api_result.text);
|
|
|
|
} else {
|
|
|
|
let mut boards = api_result.result?;
|
|
|
|
boards.sort_by(|a, b| a.name.cmp(&b.name));
|
|
|
|
boards.into_iter().for_each(|board| {
|
|
|
|
p!(ctx.prt, "{}:{}", board.id, board.name);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|