trello-to-deck/src/nextcloud/stack.rs
Paul Campbell 6552a413da
Some checks failed
Test / build (map[name:stable]) (push) Successful in 1m43s
Test / build (map[name:nightly]) (push) Successful in 2m8s
Release Please / Release-plz (push) Failing after 58s
refactor: reshuffling and extracting Executor trait
2024-12-13 21:59:28 +00:00

38 lines
934 B
Rust

//
use clap::Parser;
use crate::execute::Execute;
use crate::{p, FullCtx};
#[derive(Parser, Debug)]
pub(crate) enum NextcloudStackCommand {
List {
#[clap(long, action = clap::ArgAction::SetTrue)]
dump: bool,
},
}
impl Execute for NextcloudStackCommand {
async fn execute(self, ctx: FullCtx) -> color_eyre::Result<()> {
match self {
Self::List { dump } => list(ctx, dump).await,
}
}
}
pub(crate) async fn list(ctx: FullCtx, dump: bool) -> color_eyre::Result<()> {
let api_result = ctx
.deck_client()
.get_stacks(ctx.cfg.nextcloud.board_id)
.await;
if dump {
p!(ctx.prt, "{}", api_result.text);
} else {
let mut stacks = api_result.result?;
stacks.sort_by_key(|stack| stack.order);
stacks
.iter()
.for_each(|stack| p!(ctx.prt, "{}:{}", stack.id, stack.title));
}
Ok(())
}