Merge pull request #1 from cafkafk/cafk-basic-config
feat: proof of concept config parse
This commit is contained in:
commit
27b8b686a7
4 changed files with 29 additions and 2 deletions
15
app/Main.hs
15
app/Main.hs
|
@ -1,3 +1,5 @@
|
||||||
|
{-# LANGUAGE DeriveGeneric #-} -- (2)
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
-- import MonadRandom
|
-- import MonadRandom
|
||||||
|
@ -7,6 +9,14 @@ import Lib
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Process
|
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 :: (MonadRandom m) => m Int
|
||||||
getRandomMaidIndex = do
|
getRandomMaidIndex = do
|
||||||
let n = length maids - 1
|
let n = length maids - 1
|
||||||
|
@ -84,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!!!"
|
||||||
|
|
11
maid.cabal
11
maid.cabal
|
@ -1,6 +1,6 @@
|
||||||
cabal-version: 1.12
|
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
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
|
@ -32,8 +32,11 @@ library
|
||||||
src
|
src
|
||||||
build-depends:
|
build-depends:
|
||||||
MonadRandom >=0.6
|
MonadRandom >=0.6
|
||||||
|
, aeson
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
|
, bytestring
|
||||||
, process
|
, process
|
||||||
|
, yaml
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
executable maid
|
executable maid
|
||||||
|
@ -45,9 +48,12 @@ executable maid
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
build-depends:
|
build-depends:
|
||||||
MonadRandom >=0.6
|
MonadRandom >=0.6
|
||||||
|
, aeson
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
|
, bytestring
|
||||||
, maid
|
, maid
|
||||||
, process
|
, process
|
||||||
|
, yaml
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
test-suite maid-test
|
test-suite maid-test
|
||||||
|
@ -60,7 +66,10 @@ test-suite maid-test
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
build-depends:
|
build-depends:
|
||||||
MonadRandom >=0.6
|
MonadRandom >=0.6
|
||||||
|
, aeson
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
|
, bytestring
|
||||||
, maid
|
, maid
|
||||||
, process
|
, process
|
||||||
|
, yaml
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
|
@ -23,6 +23,9 @@ dependencies:
|
||||||
- base >= 4.7 && < 5
|
- base >= 4.7 && < 5
|
||||||
- MonadRandom >= 0.6
|
- MonadRandom >= 0.6
|
||||||
- process
|
- process
|
||||||
|
- aeson
|
||||||
|
- yaml
|
||||||
|
- bytestring
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
packages: []
|
packages: []
|
||||||
snapshots:
|
snapshots:
|
||||||
- completed:
|
- completed:
|
||||||
|
sha256: 1867d84255dff8c87373f5dd03e5a5cb1c10a99587e26c8793e750c54e83ffdc
|
||||||
size: 639139
|
size: 639139
|
||||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/0.yaml
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/0.yaml
|
||||||
sha256: 1867d84255dff8c87373f5dd03e5a5cb1c10a99587e26c8793e750c54e83ffdc
|
|
||||||
original:
|
original:
|
||||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/0.yaml
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/0.yaml
|
||||||
|
|
Loading…
Reference in a new issue