refactor(trello): rename 'trello boards list' as 'trello member get'
This commit is contained in:
parent
adb5b24886
commit
f71f8c5467
3 changed files with 43 additions and 16 deletions
|
@ -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.
|
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 board get (was list/stack list)
|
||||||
- [ ] trello stack get (was card list)
|
- [ ] trello stack get (was card list)
|
||||||
- [ ] trello card get
|
- [ ] trello card get
|
||||||
|
|
33
src/trello/member.rs
Normal file
33
src/trello/member.rs
Normal 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(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,25 +2,19 @@
|
||||||
pub(crate) mod api;
|
pub(crate) mod api;
|
||||||
pub(crate) mod boards;
|
pub(crate) mod boards;
|
||||||
pub(crate) mod client;
|
pub(crate) mod client;
|
||||||
|
pub(crate) mod member;
|
||||||
pub(crate) mod model;
|
pub(crate) mod model;
|
||||||
pub(crate) mod stack;
|
pub(crate) mod stack;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::{
|
use crate::execute::Execute;
|
||||||
execute::Execute,
|
use crate::trello::member::TrelloMemberCommand;
|
||||||
f,
|
use crate::trello::model::auth::{TrelloApiKey, TrelloApiSecret};
|
||||||
trello::{
|
use crate::trello::model::TrelloBoardName;
|
||||||
boards::TrelloBoardCommand,
|
use crate::trello::stack::TrelloStackCommand;
|
||||||
model::{
|
use crate::{f, FullCtx};
|
||||||
auth::{TrelloApiKey, TrelloApiSecret},
|
|
||||||
TrelloBoardName,
|
|
||||||
},
|
|
||||||
stack::TrelloStackCommand,
|
|
||||||
},
|
|
||||||
FullCtx,
|
|
||||||
};
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
|
@ -33,7 +27,7 @@ pub(crate) fn url(path: impl Into<String>) -> String {
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
pub(crate) enum TrelloCommand {
|
pub(crate) enum TrelloCommand {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
Board(TrelloBoardCommand),
|
Member(TrelloMemberCommand),
|
||||||
|
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
Stack(TrelloStackCommand),
|
Stack(TrelloStackCommand),
|
||||||
|
@ -42,7 +36,7 @@ pub(crate) enum TrelloCommand {
|
||||||
impl Execute for TrelloCommand {
|
impl Execute for TrelloCommand {
|
||||||
async fn execute(self, ctx: FullCtx) -> color_eyre::Result<()> {
|
async fn execute(self, ctx: FullCtx) -> color_eyre::Result<()> {
|
||||||
match self {
|
match self {
|
||||||
Self::Board(cmd) => cmd.execute(ctx).await,
|
Self::Member(cmd) => cmd.execute(ctx).await,
|
||||||
Self::Stack(cmd) => cmd.execute(ctx).await,
|
Self::Stack(cmd) => cmd.execute(ctx).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue