refactor: rearrange command dispatcher
This commit is contained in:
parent
ecc7e9097b
commit
6832c22d3d
2 changed files with 46 additions and 35 deletions
47
src/lib.rs
47
src/lib.rs
|
@ -150,24 +150,35 @@ pub async fn run(ctx: Ctx) -> color_eyre::Result<()> {
|
||||||
Command::Init => Err(eyre!("Config file already exists. Not overwriting it.")),
|
Command::Init => Err(eyre!("Config file already exists. Not overwriting it.")),
|
||||||
Command::Check => check::run(ctx).await,
|
Command::Check => check::run(ctx).await,
|
||||||
Command::Import => todo!("import"),
|
Command::Import => todo!("import"),
|
||||||
Command::Trello(TrelloCommand::Board(TrelloBoardCommand::List { dump })) => {
|
Command::Trello(trello) => match trello {
|
||||||
trello::boards::list(ctx, dump).await
|
TrelloCommand::Board(board) => match board {
|
||||||
}
|
TrelloBoardCommand::List { dump } => {
|
||||||
Command::Nextcloud(NextcloudCommand::Board(NextcloudBoardCommand::List {
|
nextcloud::board::list(ctx, dump).await
|
||||||
dump,
|
}
|
||||||
})) => nextcloud::board::list(ctx, dump).await,
|
},
|
||||||
Command::Nextcloud(NextcloudCommand::Stack(NextcloudStackCommand::List {
|
},
|
||||||
dump,
|
Command::Nextcloud(nextcloud) => match nextcloud {
|
||||||
})) => nextcloud::stack::list(ctx, dump).await,
|
NextcloudCommand::Board(board) => match board {
|
||||||
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::List {
|
NextcloudBoardCommand::List { dump } => {
|
||||||
dump,
|
nextcloud::board::list(ctx, dump).await
|
||||||
stack_id,
|
}
|
||||||
})) => nextcloud::card::list(ctx, dump, stack_id.into()).await,
|
},
|
||||||
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
|
NextcloudCommand::Stack(stack) => match stack {
|
||||||
dump,
|
NextcloudStackCommand::List { dump } => {
|
||||||
stack_id,
|
nextcloud::stack::list(ctx, dump).await
|
||||||
card_id,
|
}
|
||||||
})) => nextcloud::card::get(ctx, dump, stack_id.into(), card_id.into()).await,
|
},
|
||||||
|
NextcloudCommand::Card(card) => match card {
|
||||||
|
NextcloudCardCommand::List { dump, stack_id } => {
|
||||||
|
nextcloud::card::list(ctx, dump, stack_id.into()).await
|
||||||
|
}
|
||||||
|
NextcloudCardCommand::Get {
|
||||||
|
dump,
|
||||||
|
stack_id,
|
||||||
|
card_id,
|
||||||
|
} => nextcloud::card::get(ctx, dump, stack_id.into(), card_id.into()).await,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
//
|
//
|
||||||
use crate::{p, FullCtx};
|
// use crate::{p, FullCtx};
|
||||||
|
//
|
||||||
pub(crate) async fn list(ctx: FullCtx, dump: bool) -> color_eyre::Result<()> {
|
// pub(crate) async fn list(ctx: FullCtx, dump: bool) -> color_eyre::Result<()> {
|
||||||
let api_result =
|
// let api_result =
|
||||||
super::api::members::get_boards_that_member_belongs_to(&ctx.cfg.trello, &ctx.net, &ctx.prt)
|
// super::api::members::get_boards_that_member_belongs_to(&ctx.cfg.trello, &ctx.net, &ctx.prt)
|
||||||
.await;
|
// .await;
|
||||||
if dump {
|
// if dump {
|
||||||
p!(ctx.prt, "{}", api_result.text);
|
// p!(ctx.prt, "{}", api_result.text);
|
||||||
} else {
|
// } else {
|
||||||
let mut boards = api_result.result?;
|
// let mut boards = api_result.result?;
|
||||||
boards.sort_by(|a, b| a.name.cmp(&b.name));
|
// boards.sort_by(|a, b| a.name.cmp(&b.name));
|
||||||
boards.into_iter().for_each(|board| {
|
// boards.into_iter().for_each(|board| {
|
||||||
p!(ctx.prt, "{}:{}", board.id, board.name);
|
// p!(ctx.prt, "{}:{}", board.id, board.name);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
|
|
Loading…
Reference in a new issue