// 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(()) }