feat: proof of concept config parse

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2023-10-12 15:50:55 +02:00
parent f470601503
commit de41aa4dc2
Signed by: cafkafk
GPG key ID: 26C542FD97F965CE

View file

@ -14,6 +14,9 @@ import qualified Data.Yaml as Y
import GHC.Generics import GHC.Generics
import Data.Aeson 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 :: (MonadRandom m) => m Int
getRandomMaidIndex = do getRandomMaidIndex = do
let n = length maids - 1 let n = length maids - 1
@ -91,6 +94,11 @@ performCleanup = do
main :: IO () main :: IO ()
main = do 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 maid <- getRandomMaid
putStrLn maid putStrLn maid
putStrLn "[+] !!!Cleaning Time!!!" putStrLn "[+] !!!Cleaning Time!!!"