blob: f3d9fee912c3e53071a514ef7ead84a9a0704501 [file] [log] [blame]
Matthias Andreas Benkard262110d2021-08-24 06:35:55 +02001{-# LANGUAGE UndecidableInstances #-}
2
3module Mulkup.Config (TierConfig (..), MulkupConfig (..), readConfig) where
4
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