diff --git a/app/Main.hs b/app/Main.hs index 3952c81..67b5ab6 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE DeriveGeneric #-} -- (2) + module Main where -- import MonadRandom @@ -7,6 +9,14 @@ import Lib import System.IO import System.Process +import qualified Data.ByteString.Char8 as BS +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 @@ -84,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!!!" diff --git a/maid.cabal b/maid.cabal index fe1a79b..44064bb 100644 --- a/maid.cabal +++ b/maid.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.5. +-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack @@ -32,8 +32,11 @@ library src build-depends: MonadRandom >=0.6 + , aeson , base >=4.7 && <5 + , bytestring , process + , yaml default-language: Haskell2010 executable maid @@ -45,9 +48,12 @@ executable maid ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: MonadRandom >=0.6 + , aeson , base >=4.7 && <5 + , bytestring , maid , process + , yaml default-language: Haskell2010 test-suite maid-test @@ -60,7 +66,10 @@ test-suite maid-test ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: MonadRandom >=0.6 + , aeson , base >=4.7 && <5 + , bytestring , maid , process + , yaml default-language: Haskell2010 diff --git a/package.yaml b/package.yaml index 053ad3b..982de77 100644 --- a/package.yaml +++ b/package.yaml @@ -23,6 +23,9 @@ dependencies: - base >= 4.7 && < 5 - MonadRandom >= 0.6 - process + - aeson + - yaml + - bytestring library: source-dirs: src diff --git a/stack.yaml.lock b/stack.yaml.lock index 7ce337e..1cbe28f 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -6,8 +6,8 @@ packages: [] snapshots: - completed: + sha256: 1867d84255dff8c87373f5dd03e5a5cb1c10a99587e26c8793e750c54e83ffdc size: 639139 url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/0.yaml - sha256: 1867d84255dff8c87373f5dd03e5a5cb1c10a99587e26c8793e750c54e83ffdc original: url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/0.yaml