2023-08-09 20:59:42 +02:00
|
|
|
module SlackBuilder.Config
|
|
|
|
( Settings(..)
|
2023-08-28 21:05:47 +02:00
|
|
|
, MaintainerSettings(..)
|
2023-08-09 20:59:42 +02:00
|
|
|
, settingsCodec
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Data.Text (Text)
|
|
|
|
import Toml ((.=))
|
|
|
|
import qualified Toml
|
|
|
|
|
2023-08-15 10:33:19 +02:00
|
|
|
data Settings = Settings
|
|
|
|
{ ghToken :: !Text
|
|
|
|
, repository :: !FilePath
|
|
|
|
, branch :: Text
|
2023-08-17 22:07:09 +02:00
|
|
|
, downloadURL :: Text
|
2023-08-18 07:50:18 +02:00
|
|
|
, remotePath :: Text
|
2023-08-28 21:05:47 +02:00
|
|
|
, maintainer :: MaintainerSettings
|
|
|
|
} deriving (Eq, Show)
|
|
|
|
|
|
|
|
data MaintainerSettings = MaintainerSettings
|
|
|
|
{ name :: !Text
|
|
|
|
, email :: !Text
|
2023-09-27 19:58:16 +02:00
|
|
|
, signature :: !Bool
|
2023-08-09 20:59:42 +02:00
|
|
|
} deriving (Eq, Show)
|
|
|
|
|
|
|
|
settingsCodec :: Toml.TomlCodec Settings
|
|
|
|
settingsCodec = Settings
|
|
|
|
<$> Toml.text "gh_token" .= ghToken
|
2023-08-15 10:33:19 +02:00
|
|
|
<*> Toml.string "repository" .= repository
|
|
|
|
<*> Toml.text "branch" .= branch
|
2023-08-17 22:07:09 +02:00
|
|
|
<*> Toml.text "download_url" .= downloadURL
|
2023-08-18 07:50:18 +02:00
|
|
|
<*> Toml.text "remote_path" .= remotePath
|
2023-08-28 21:05:47 +02:00
|
|
|
<*> Toml.table maintainerSettingsCodec "maintainer" .= maintainer
|
|
|
|
|
|
|
|
maintainerSettingsCodec :: Toml.TomlCodec MaintainerSettings
|
|
|
|
maintainerSettingsCodec = MaintainerSettings
|
|
|
|
<$> Toml.text "name" .= name
|
|
|
|
<*> Toml.text "email" .= email
|
2023-09-27 19:58:16 +02:00
|
|
|
<*> Toml.bool "signature" .= signature
|