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