refactor: command 'nextcloud card get' takes board id from parameters
This commit is contained in:
parent
0047f5d0ef
commit
7cf6f9bd94
3 changed files with 24 additions and 28 deletions
|
@ -77,7 +77,7 @@ As part of building the import server, the following commands exercise each oper
|
|||
- [x] nextcloud deck get - includes list of boards
|
||||
- [x] nextcloud board get - includes list of stacks
|
||||
- [x] nextcloud stack get - includes list of cards
|
||||
- [ ] nextcloud card get - shows card title
|
||||
- [x] nextcloud card get - shows card title
|
||||
- [ ] nextcloud card create
|
||||
- [ ] nextcloud card add-label
|
||||
- [ ] nextcloud card add-attachment
|
|
@ -13,6 +13,7 @@ pub enum NextcloudCardCommand {
|
|||
Get {
|
||||
#[clap(long, action = clap::ArgAction::SetTrue)]
|
||||
dump: bool,
|
||||
board_id: i64,
|
||||
stack_id: i64,
|
||||
card_id: i64,
|
||||
},
|
||||
|
@ -40,16 +41,28 @@ impl Execute for NextcloudCardCommand {
|
|||
match self {
|
||||
Self::Get {
|
||||
dump,
|
||||
board_id,
|
||||
stack_id,
|
||||
card_id,
|
||||
} => {
|
||||
get(
|
||||
ctx,
|
||||
*dump,
|
||||
NextcloudStackId::from(*stack_id),
|
||||
NextcloudCardId::from(*card_id),
|
||||
)
|
||||
.await
|
||||
let api_result = ctx
|
||||
.deck_client()
|
||||
.get_card((*board_id).into(), (*stack_id).into(), (*card_id).into())
|
||||
.await;
|
||||
if *dump {
|
||||
p!(ctx.prt, "{}", api_result.text);
|
||||
} else {
|
||||
let card = api_result.result?;
|
||||
p!(
|
||||
ctx.prt,
|
||||
"{}:{}:{}:{}",
|
||||
board_id,
|
||||
stack_id,
|
||||
card_id,
|
||||
card.title
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Self::Create {
|
||||
dump,
|
||||
|
@ -89,25 +102,6 @@ impl Execute for NextcloudCardCommand {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn get(
|
||||
ctx: &FullCtx,
|
||||
dump: bool,
|
||||
stack_id: NextcloudStackId,
|
||||
card_id: NextcloudCardId,
|
||||
) -> color_eyre::Result<()> {
|
||||
let api_result = ctx
|
||||
.deck_client()
|
||||
.get_card(ctx.cfg.nextcloud.board_id, stack_id, card_id)
|
||||
.await;
|
||||
if dump {
|
||||
p!(ctx.prt, "{}", api_result.text);
|
||||
} else {
|
||||
let card = api_result.result?;
|
||||
p!(ctx.prt, "{}:{}", card.id, card.title);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) struct Create {
|
||||
pub(crate) dump: bool,
|
||||
pub(crate) stack_id: NextcloudStackId,
|
||||
|
|
|
@ -51,6 +51,7 @@ async fn dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCardId
|
|||
//when
|
||||
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
|
||||
dump: true,
|
||||
board_id: ctx.cfg.nextcloud.board_id.into(),
|
||||
stack_id: stack_id.into(),
|
||||
card_id: card_id.into(),
|
||||
}))
|
||||
|
@ -76,6 +77,7 @@ async fn no_dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCar
|
|||
//when
|
||||
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
|
||||
dump: false,
|
||||
board_id: ctx.cfg.nextcloud.board_id.into(),
|
||||
stack_id: stack_id.into(),
|
||||
card_id: card_id.into(),
|
||||
}))
|
||||
|
@ -85,5 +87,5 @@ async fn no_dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCar
|
|||
|
||||
//then
|
||||
let output = prt.output();
|
||||
assert_peq!(output.trim(), "321:Breakfast: Cereal");
|
||||
assert_peq!(output.trim(), "2:1:321:Breakfast: Cereal");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue