From 6ee44dc7d4348b05cce5ea2d36c4c4c93646ac53 Mon Sep 17 00:00:00 2001
From: Paul Campbell <campbjpa@amazon.com>
Date: Sat, 14 Dec 2024 08:25:38 +0000
Subject: [PATCH] feat: check command lists trello boards

---
 src/check.rs | 61 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/src/check.rs b/src/check.rs
index fd5342c..642f41a 100644
--- a/src/check.rs
+++ b/src/check.rs
@@ -4,34 +4,43 @@ use color_eyre::eyre::{OptionExt as _, Result};
 use crate::{f, p, trello::model::board::TrelloBoards as _, FullCtx};
 
 pub(crate) async fn run(ctx: FullCtx) -> Result<()> {
-    // test trello by getting a list of the boards for the user
-    p!(ctx.prt, ">> Testing Trello details...");
-    let boards = ctx.trello_client().boards().await.result?;
-    p!(ctx.prt, "<<< Trello Credentials: OKAY");
-    let board_name = &ctx.cfg.trello.board_name;
-    p!(ctx.prt, ">> Trello Board: {board_name}");
-    let board = boards
-        .find_by_name(board_name)
-        .ok_or_eyre(f!("board not found: {board_name}"))?;
-    p!(ctx.prt, "<<< Trello Board: OKAY");
-    for list in &board.lists {
-        p!(ctx.prt, "<<< List: {}", list.name);
+    {
+        // test trello by getting a list of the boards for the user
+        p!(ctx.prt, ">> Testing Trello details...");
+        let boards = ctx.trello_client().boards().await.result?;
+        p!(ctx.prt, "<<< Trello Credentials: OKAY");
+        let board_name = &ctx.cfg.trello.board_name;
+        p!(ctx.prt, ">> Trello Board: {board_name}");
+        let board = boards
+            .find_by_name(board_name)
+            .ok_or_eyre(f!("board not found: {board_name}"))?;
+        p!(ctx.prt, "<<< Trello Board: OKAY");
+        for list in &board.lists {
+            p!(ctx.prt, "<<<< List: {}", list.name);
+        }
     }
 
-    p!(ctx.prt, ">> Testing Nextcloud details...");
-    let deck_client = ctx.deck_client();
-    let board = deck_client
-        .get_board(ctx.cfg.nextcloud.board_id)
-        .await
-        .result?;
-    p!(ctx.prt, "<<< Nextcloud Credentials: OKAY");
-    p!(ctx.prt, "<<< Nextcloud Board: {}", board.title);
-    let stacks = deck_client
-        .get_stacks(ctx.cfg.nextcloud.board_id)
-        .await
-        .result?;
-    for stack in stacks {
-        p!(ctx.prt, "<<< Stack: {}", stack.title);
+    {
+        p!(ctx.prt, ">> Testing Nextcloud details...");
+        let deck_client = ctx.deck_client();
+        let boards = deck_client.get_boards().await.result?;
+        p!(ctx.prt, "<<< Nextcloud Boards");
+        for board in &boards {
+            p!(ctx.prt, "<<<< Board: {}", board.title);
+        }
+        p!(ctx.prt, "<<< Nextcloud Credentials: OKAY");
+        let board = boards
+            .iter()
+            .find(|b| b.id == ctx.cfg.nextcloud.board_id)
+            .ok_or_eyre("board not found")?;
+        p!(ctx.prt, "<<< Nextcloud Board: {}", board.title);
+        let stacks = deck_client
+            .get_stacks(ctx.cfg.nextcloud.board_id)
+            .await
+            .result?;
+        for stack in stacks {
+            p!(ctx.prt, "<<<< Stack: {}", stack.title);
+        }
     }
 
     Ok(())