diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-10-01 19:54:32 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-10-01 19:54:32 +0200 |
| commit | 6290be859dc9641a7f83231778e786b60a8d0d2e (patch) | |
| tree | 0571b18cade4594f521fceca77240d7366fe816c /lib/SlackBuilder/Config.hs | |
| parent | f395d57b33b0fbf36c40358fb00b29ea3f96aea0 (diff) | |
| download | slackbuilder-6290be859dc9641a7f83231778e786b60a8d0d2e.tar.gz | |
Wrap common downloader fields into a record
Diffstat (limited to 'lib/SlackBuilder/Config.hs')
| -rw-r--r-- | lib/SlackBuilder/Config.hs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/SlackBuilder/Config.hs b/lib/SlackBuilder/Config.hs index 995432f..88d2253 100644 --- a/lib/SlackBuilder/Config.hs +++ b/lib/SlackBuilder/Config.hs @@ -4,7 +4,8 @@ -- | Configuration file. module SlackBuilder.Config - ( Settings(..) + ( DownloaderSettings(..) + , Settings(..) , MaintainerSettings(..) , PackageSettings(..) , settingsCodec @@ -14,6 +15,7 @@ import Data.List.NonEmpty (NonEmpty(..)) import Data.Text (Text) import Toml ((.=)) import qualified Toml +import GHC.Records (HasField(..)) data Settings = Settings { ghToken :: !Text @@ -29,7 +31,7 @@ newtype MaintainerSettings = MaintainerSettings { signature :: Bool } deriving (Eq, Show) -data PackageSettings = PackageSettings +data DownloaderSettings = DownloaderSettings { name :: Text , template :: Text , is64 :: Bool @@ -40,6 +42,10 @@ data PackageSettings = PackageSettings , repackage :: Maybe [String] } deriving (Eq, Show) +newtype PackageSettings = PackageSettings + { downloader :: DownloaderSettings + } deriving (Eq, Show) + settingsCodec :: Toml.TomlCodec Settings settingsCodec = Settings <$> Toml.text "gh_token" .= ghToken @@ -54,8 +60,8 @@ maintainerSettingsCodec :: Toml.TomlCodec MaintainerSettings maintainerSettingsCodec = MaintainerSettings <$> Toml.bool "signature" .= signature -packageSettingsCodec :: Toml.TomlCodec PackageSettings -packageSettingsCodec = PackageSettings +downloaderSettingsCodec :: Toml.TomlCodec DownloaderSettings +downloaderSettingsCodec = DownloaderSettings <$> Toml.text "name" .= name <*> Toml.text "template" .= template <*> Toml.bool "is64" .= is64 @@ -68,3 +74,6 @@ packageSettingsCodec = PackageSettings githubCodec = Toml.pair (Toml.text "owner") (Toml.text "name") packagistCodec = Toml.pair (Toml.text "owner") (Toml.text "name") textCodec = Toml.pair (Toml.text "url") (Toml.arrayOf Toml._String "picker") + +packageSettingsCodec :: Toml.TomlCodec PackageSettings +packageSettingsCodec = Toml.dimap (getField @"downloader") PackageSettings downloaderSettingsCodec |
