blob: 83568249605bb0a88d732af9f6ecbc6d68ee85e6 [file] [log] [blame]
Matthias Andreas Benkard47eddb52024-08-30 18:47:33 +02001{-# LANGUAGE TypeOperators #-}
Matthias Andreas Benkard262110d2021-08-24 06:35:55 +02002{-# LANGUAGE UndecidableInstances #-}
3
Matthias Andreas Benkard178f9912024-08-30 18:44:51 +02004module Mulkup.Config (TierConfig (..), TierConfigs (..), StashConfig (..), MulkupConfig (..), readConfig) where
Matthias Andreas Benkard262110d2021-08-24 06:35:55 +02005
6import Dhall
7import Mulkup.Prelude
8import Optics.TH
9
10--- TierConfig ---
11
12data TierConfig = TierConfig {keep :: Natural}
13 deriving stock (Generic, Show)
14 deriving anyclass (FromDhall)
15
16makeFieldLabelsNoPrefix ''TierConfig
17
18--- TierConfigs ---
19
20data TierConfigs = TierConfigs {hourly :: TierConfig, daily :: TierConfig, weekly :: TierConfig, monthly :: TierConfig}
21 deriving stock (Generic, Show)
22 deriving anyclass (FromDhall)
23
24makeFieldLabelsNoPrefix ''TierConfigs
25
26--- StashConfigs ---
27
28data StashConfig = StashConfig {name :: Text, baseDir :: Text, tiers :: TierConfigs, exclusions :: [Text]}
29 deriving stock (Generic, Show)
30 deriving anyclass (FromDhall)
31
32makeFieldLabelsNoPrefix ''StashConfig
33
34--- MulkupConfig ---
35
36data MulkupConfig = MulkupConfig {host :: Text, stashes :: [StashConfig]}
37 deriving stock (Generic, Show)
38 deriving anyclass (FromDhall)
39
40makeFieldLabelsNoPrefix ''MulkupConfig
41
42--- readConfig ---
43
44readConfig :: Text -> IO MulkupConfig
45readConfig = Dhall.input auto