2023-12-23 22:15:10 +01:00
|
|
|
{- This Source Code Form is subject to the terms of the Mozilla Public License,
|
|
|
|
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
|
obtain one at https://mozilla.org/MPL/2.0/. -}
|
|
|
|
|
2023-12-12 18:51:44 +01:00
|
|
|
-- | Configuration file.
|
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
|
|
|
|
|
2024-05-11 19:01:41 +02:00
|
|
|
import Data.List.NonEmpty (NonEmpty(..))
|
2023-08-09 20:59:42 +02:00
|
|
|
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
|
2024-05-11 19:01:41 +02:00
|
|
|
, uploadCommand :: NonEmpty Text
|
2023-08-28 21:05:47 +02:00
|
|
|
, maintainer :: MaintainerSettings
|
|
|
|
} deriving (Eq, Show)
|
|
|
|
|
2023-10-08 12:28:46 +02:00
|
|
|
newtype MaintainerSettings = MaintainerSettings
|
|
|
|
{ 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
|
2024-05-11 19:01:41 +02:00
|
|
|
<*> Toml.arrayNonEmptyOf Toml._Text "upload_command" .= uploadCommand
|
2023-08-28 21:05:47 +02:00
|
|
|
<*> Toml.table maintainerSettingsCodec "maintainer" .= maintainer
|
|
|
|
|
|
|
|
maintainerSettingsCodec :: Toml.TomlCodec MaintainerSettings
|
|
|
|
maintainerSettingsCodec = MaintainerSettings
|
2023-10-08 12:28:46 +02:00
|
|
|
<$> Toml.bool "signature" .= signature
|