Merge pull request #1 from cafkafk/cafk-basic-config

feat: proof of concept config parse
This commit is contained in:
Christina Sørensen 2023-10-12 13:51:58 +00:00 committed by GitHub
commit 27b8b686a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 2 deletions

View file

@ -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!!!"

View file

@ -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

View file

@ -23,6 +23,9 @@ dependencies:
- base >= 4.7 && < 5
- MonadRandom >= 0.6
- process
- aeson
- yaml
- bytestring
library:
source-dirs: src

View file

@ -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