{-# LANGUAGE NoImplicitPrelude #-}
module Headroom.Command.Utils
( bootstrap
)
where
import RIO
bootstrap :: (LogFunc -> IO env)
-> Bool
-> RIO env a
-> IO a
bootstrap :: (LogFunc -> IO env) -> Bool -> RIO env a -> IO a
bootstrap LogFunc -> IO env
getEnv Bool
isDebug RIO env a
logic = do
LogOptions
logOptions <- Handle -> Bool -> IO LogOptions
forall (m :: * -> *). MonadIO m => Handle -> Bool -> m LogOptions
logOptionsHandle Handle
stderr Bool
isDebug
let logOptions' :: LogOptions
logOptions' = Bool -> LogOptions -> LogOptions
setLogUseLoc Bool
False LogOptions
logOptions
LogOptions -> (LogFunc -> IO a) -> IO a
forall (m :: * -> *) a.
MonadUnliftIO m =>
LogOptions -> (LogFunc -> m a) -> m a
withLogFunc LogOptions
logOptions' ((LogFunc -> IO a) -> IO a) -> (LogFunc -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \LogFunc
logFunc -> do
env
env <- IO env -> IO env
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO env -> IO env) -> IO env -> IO env
forall a b. (a -> b) -> a -> b
$ LogFunc -> IO env
getEnv LogFunc
logFunc
env -> RIO env a -> IO a
forall (m :: * -> *) env a. MonadIO m => env -> RIO env a -> m a
runRIO env
env RIO env a
logic