blob: 4be5b642db232d35ba68ba6bc91d1ba824748a89 [file] [log] [blame]
{-# LANGUAGE UndecidableInstances #-}
module Mulkup.Config (TierConfig (..), TierConfigs (..), StashConfig (..), MulkupConfig (..), readConfig) where
import Dhall
import Mulkup.Prelude
import Optics.TH
--- TierConfig ---
data TierConfig = TierConfig {keep :: Natural}
deriving stock (Generic, Show)
deriving anyclass (FromDhall)
makeFieldLabelsNoPrefix ''TierConfig
--- TierConfigs ---
data TierConfigs = TierConfigs {hourly :: TierConfig, daily :: TierConfig, weekly :: TierConfig, monthly :: TierConfig}
deriving stock (Generic, Show)
deriving anyclass (FromDhall)
makeFieldLabelsNoPrefix ''TierConfigs
--- StashConfigs ---
data StashConfig = StashConfig {name :: Text, baseDir :: Text, tiers :: TierConfigs, exclusions :: [Text]}
deriving stock (Generic, Show)
deriving anyclass (FromDhall)
makeFieldLabelsNoPrefix ''StashConfig
--- MulkupConfig ---
data MulkupConfig = MulkupConfig {host :: Text, stashes :: [StashConfig]}
deriving stock (Generic, Show)
deriving anyclass (FromDhall)
makeFieldLabelsNoPrefix ''MulkupConfig
--- readConfig ---
readConfig :: Text -> IO MulkupConfig
readConfig = Dhall.input auto