trello-to-deck/src/trello/boards.rs
Paul Campbell 42ec361ff2
Some checks failed
Test / build (map[name:stable]) (push) Successful in 1m41s
Test / build (map[name:nightly]) (push) Successful in 2m10s
Release Please / Release-plz (push) Failing after 16s
refactor(trello): rewrite trello module and rename commands
2024-12-13 22:10:38 +00:00

34 lines
868 B
Rust

//
use clap::Parser;
use crate::{execute::Execute, p, FullCtx};
#[derive(Parser, Debug)]
pub(crate) enum TrelloBoardCommand {
List {
#[clap(long, action = clap::ArgAction::SetTrue)]
dump: bool,
},
}
impl Execute for TrelloBoardCommand {
async fn execute(self, ctx: FullCtx) -> color_eyre::Result<()> {
match self {
Self::List { dump } => list(ctx, dump).await,
}
}
}
pub(crate) async fn list(ctx: FullCtx, dump: bool) -> color_eyre::Result<()> {
let api_result = ctx.trello_client().boards().await;
if dump {
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(())
}