From de41aa4dc29e1fda7c799427d8c1f0a3ab7b1dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Thu, 12 Oct 2023 15:50:55 +0200 Subject: [PATCH] feat: proof of concept config parse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christina Sørensen --- app/Main.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Main.hs b/app/Main.hs index a3da4a2..67b5ab6 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -14,6 +14,9 @@ import qualified Data.Yaml as Y import GHC.Generics import Data.Aeson +data Cred = Cred { example :: String, other :: String } deriving (Show, Generic) -- (1,2) +instance FromJSON Cred -- (3) + getRandomMaidIndex :: (MonadRandom m) => m Int getRandomMaidIndex = do let n = length maids - 1 @@ -91,6 +94,11 @@ performCleanup = do main :: IO () main = do + content <- BS.readFile "config.yaml" -- (4) + let parsedContent = Y.decode content :: Maybe Cred -- (5) + case parsedContent of + Nothing -> putStrLn "[-] no config found" + (Just (Cred u p)) -> putStrLn ("[+] example: " ++ u ++ ", other: " ++ p) maid <- getRandomMaid putStrLn maid putStrLn "[+] !!!Cleaning Time!!!"