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 deck get - includes list of boards
|
||||||
- [x] nextcloud board get - includes list of stacks
|
- [x] nextcloud board get - includes list of stacks
|
||||||
- [x] nextcloud stack get - includes list of cards
|
- [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 create
|
||||||
- [ ] nextcloud card add-label
|
- [ ] nextcloud card add-label
|
||||||
- [ ] nextcloud card add-attachment
|
- [ ] nextcloud card add-attachment
|
|
@ -13,6 +13,7 @@ pub enum NextcloudCardCommand {
|
||||||
Get {
|
Get {
|
||||||
#[clap(long, action = clap::ArgAction::SetTrue)]
|
#[clap(long, action = clap::ArgAction::SetTrue)]
|
||||||
dump: bool,
|
dump: bool,
|
||||||
|
board_id: i64,
|
||||||
stack_id: i64,
|
stack_id: i64,
|
||||||
card_id: i64,
|
card_id: i64,
|
||||||
},
|
},
|
||||||
|
@ -40,16 +41,28 @@ impl Execute for NextcloudCardCommand {
|
||||||
match self {
|
match self {
|
||||||
Self::Get {
|
Self::Get {
|
||||||
dump,
|
dump,
|
||||||
|
board_id,
|
||||||
stack_id,
|
stack_id,
|
||||||
card_id,
|
card_id,
|
||||||
} => {
|
} => {
|
||||||
get(
|
let api_result = ctx
|
||||||
ctx,
|
.deck_client()
|
||||||
*dump,
|
.get_card((*board_id).into(), (*stack_id).into(), (*card_id).into())
|
||||||
NextcloudStackId::from(*stack_id),
|
.await;
|
||||||
NextcloudCardId::from(*card_id),
|
if *dump {
|
||||||
)
|
p!(ctx.prt, "{}", api_result.text);
|
||||||
.await
|
} else {
|
||||||
|
let card = api_result.result?;
|
||||||
|
p!(
|
||||||
|
ctx.prt,
|
||||||
|
"{}:{}:{}:{}",
|
||||||
|
board_id,
|
||||||
|
stack_id,
|
||||||
|
card_id,
|
||||||
|
card.title
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
Self::Create {
|
Self::Create {
|
||||||
dump,
|
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) struct Create {
|
||||||
pub(crate) dump: bool,
|
pub(crate) dump: bool,
|
||||||
pub(crate) stack_id: NextcloudStackId,
|
pub(crate) stack_id: NextcloudStackId,
|
||||||
|
|
|
@ -51,6 +51,7 @@ async fn dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCardId
|
||||||
//when
|
//when
|
||||||
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
|
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
|
||||||
dump: true,
|
dump: true,
|
||||||
|
board_id: ctx.cfg.nextcloud.board_id.into(),
|
||||||
stack_id: stack_id.into(),
|
stack_id: stack_id.into(),
|
||||||
card_id: card_id.into(),
|
card_id: card_id.into(),
|
||||||
}))
|
}))
|
||||||
|
@ -76,6 +77,7 @@ async fn no_dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCar
|
||||||
//when
|
//when
|
||||||
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
|
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
|
||||||
dump: false,
|
dump: false,
|
||||||
|
board_id: ctx.cfg.nextcloud.board_id.into(),
|
||||||
stack_id: stack_id.into(),
|
stack_id: stack_id.into(),
|
||||||
card_id: card_id.into(),
|
card_id: card_id.into(),
|
||||||
}))
|
}))
|
||||||
|
@ -85,5 +87,5 @@ async fn no_dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCar
|
||||||
|
|
||||||
//then
|
//then
|
||||||
let output = prt.output();
|
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