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