Matthias Andreas Benkard | 262110d | 2021-08-24 06:35:55 +0200 | [diff] [blame^] | 1 | {-# LANGUAGE UndecidableInstances #-} |
| 2 | |
| 3 | module Mulkup.Config (TierConfig (..), MulkupConfig (..), readConfig) where |
| 4 | |
| 5 | import Dhall |
| 6 | import Mulkup.Prelude |
| 7 | import Optics.TH |
| 8 | |
| 9 | --- TierConfig --- |
| 10 | |
| 11 | data TierConfig = TierConfig {keep :: Natural} |
| 12 | deriving stock (Generic, Show) |
| 13 | deriving anyclass (FromDhall) |
| 14 | |
| 15 | makeFieldLabelsNoPrefix ''TierConfig |
| 16 | |
| 17 | --- TierConfigs --- |
| 18 | |
| 19 | data TierConfigs = TierConfigs {hourly :: TierConfig, daily :: TierConfig, weekly :: TierConfig, monthly :: TierConfig} |
| 20 | deriving stock (Generic, Show) |
| 21 | deriving anyclass (FromDhall) |
| 22 | |
| 23 | makeFieldLabelsNoPrefix ''TierConfigs |
| 24 | |
| 25 | --- StashConfigs --- |
| 26 | |
| 27 | data StashConfig = StashConfig {name :: Text, baseDir :: Text, tiers :: TierConfigs, exclusions :: [Text]} |
| 28 | deriving stock (Generic, Show) |
| 29 | deriving anyclass (FromDhall) |
| 30 | |
| 31 | makeFieldLabelsNoPrefix ''StashConfig |
| 32 | |
| 33 | --- MulkupConfig --- |
| 34 | |
| 35 | data MulkupConfig = MulkupConfig {host :: Text, stashes :: [StashConfig]} |
| 36 | deriving stock (Generic, Show) |
| 37 | deriving anyclass (FromDhall) |
| 38 | |
| 39 | makeFieldLabelsNoPrefix ''MulkupConfig |
| 40 | |
| 41 | --- readConfig --- |
| 42 | |
| 43 | readConfig :: Text -> IO MulkupConfig |
| 44 | readConfig = Dhall.input auto |