refactor(trello): rename 'trello boards list' as 'trello member get'

This commit is contained in:
Paul Campbell 2024-12-09 13:40:55 +00:00
parent adb5b24886
commit f71f8c5467
3 changed files with 43 additions and 16 deletions

View file

@ -60,7 +60,7 @@ trello-to-deck check
As part of building the import server, I'm including the following commands the exercise each operation invovled.
- [ ] trello member get (was boards list)
- [x] trello member get
- [ ] trello board get (was list/stack list)
- [ ] trello stack get (was card list)
- [ ] trello card get

33
src/trello/member.rs Normal file
View file

@ -0,0 +1,33 @@
//
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 {
async fn execute(self, ctx: FullCtx) -> color_eyre::Result<()> {
match self {
Self::Get { dump } => {
let api_result = ctx.trello_client().boards(&ctx.cfg.trello).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(())
}
}
}
}

View file

@ -2,25 +2,19 @@
pub(crate) mod api;
pub(crate) mod boards;
pub(crate) mod client;
pub(crate) mod member;
pub(crate) mod model;
pub(crate) mod stack;
#[cfg(test)]
mod tests;
use crate::{
execute::Execute,
f,
trello::{
boards::TrelloBoardCommand,
model::{
auth::{TrelloApiKey, TrelloApiSecret},
TrelloBoardName,
},
stack::TrelloStackCommand,
},
FullCtx,
};
use crate::execute::Execute;
use crate::trello::member::TrelloMemberCommand;
use crate::trello::model::auth::{TrelloApiKey, TrelloApiSecret};
use crate::trello::model::TrelloBoardName;
use crate::trello::stack::TrelloStackCommand;
use crate::{f, FullCtx};
use clap::Parser;
@ -33,7 +27,7 @@ pub(crate) fn url(path: impl Into<String>) -> String {
#[derive(Parser, Debug)]
pub(crate) enum TrelloCommand {
#[clap(subcommand)]
Board(TrelloBoardCommand),
Member(TrelloMemberCommand),
#[clap(subcommand)]
Stack(TrelloStackCommand),
@ -42,7 +36,7 @@ pub(crate) enum TrelloCommand {
impl Execute for TrelloCommand {
async fn execute(self, ctx: FullCtx) -> color_eyre::Result<()> {
match self {
Self::Board(cmd) => cmd.execute(ctx).await,
Self::Member(cmd) => cmd.execute(ctx).await,
Self::Stack(cmd) => cmd.execute(ctx).await,
}
}