diff options
| author | LLLL Colonq <llll@colonq> | 2023-11-16 19:06:43 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2023-11-16 19:06:43 -0500 |
| commit | dcef0b65069fb38fd0f6c4382353167f603ebff1 (patch) | |
| tree | 45954ffe308c3dd056e6af4f734e6d2af89e5856 /fig-monitor-bullfrog/src/Fig/Monitor/Bullfrog/Utils.hs | |
Initial commit
Diffstat (limited to 'fig-monitor-bullfrog/src/Fig/Monitor/Bullfrog/Utils.hs')
| -rw-r--r-- | fig-monitor-bullfrog/src/Fig/Monitor/Bullfrog/Utils.hs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fig-monitor-bullfrog/src/Fig/Monitor/Bullfrog/Utils.hs b/fig-monitor-bullfrog/src/Fig/Monitor/Bullfrog/Utils.hs new file mode 100644 index 0000000..b0ae02b --- /dev/null +++ b/fig-monitor-bullfrog/src/Fig/Monitor/Bullfrog/Utils.hs @@ -0,0 +1,29 @@ +{-# Language ApplicativeDo #-} + +module Fig.Monitor.Bullfrog.Utils + ( FigMonitorBullfrogException(..) + , Config(..) + , loadConfig + ) where + +import Fig.Prelude + +import qualified Toml + +newtype FigMonitorBullfrogException = FigMonitorBullfrogException Text + deriving (Show, Eq, Ord) +instance Exception FigMonitorBullfrogException + +newtype Config = Config + { authToken :: Text + } deriving (Show, Eq, Ord) + +configCodec :: Toml.TomlCodec Config +configCodec = do + authToken <- Toml.text "auth_token" Toml..= (\a -> a.authToken) + pure $ Config{..} + +loadConfig :: FilePath -> IO Config +loadConfig path = Toml.decodeFileEither configCodec path >>= \case + Left err -> throwM . FigMonitorBullfrogException $ tshow err + Right config -> pure config |
