2019-10-18 00:06:25 +03:00
|
|
|
module PierConfig where
|
|
|
|
|
|
|
|
import UrbitPrelude
|
|
|
|
|
2019-10-18 02:10:53 +03:00
|
|
|
data NetworkingType = NetworkNone | NetworkNormal | NetworkLocalhost
|
2019-10-18 00:06:25 +03:00
|
|
|
|
|
|
|
-- All the configuration data revolving around a ship and the current execution
|
|
|
|
-- options.
|
|
|
|
data PierConfig = PierConfig
|
|
|
|
{ pcPierPath :: FilePath
|
2019-10-18 02:10:53 +03:00
|
|
|
, pcDryRun :: Bool
|
2019-10-18 00:06:25 +03:00
|
|
|
-- Configurable networking options
|
|
|
|
, pcNetworking :: NetworkingType
|
2019-10-18 01:32:06 +03:00
|
|
|
, pcAmesPort :: Maybe Word16
|
2019-10-18 00:06:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
class HasPierConfig env where
|
|
|
|
pierConfigL :: Lens' env PierConfig
|
|
|
|
|
|
|
|
getPierPath :: (MonadReader env m, HasPierConfig env) => m FilePath
|
|
|
|
getPierPath = do
|
|
|
|
PierConfig{..} <- view pierConfigL
|
|
|
|
pure pcPierPath
|
|
|
|
|
2019-10-18 02:10:53 +03:00
|
|
|
getIsDryRun :: (MonadReader env m, HasPierConfig env) => m Bool
|
|
|
|
getIsDryRun = do
|
|
|
|
PierConfig{..} <- view pierConfigL
|
|
|
|
pure pcDryRun
|
|
|
|
|
2019-10-18 00:06:25 +03:00
|
|
|
getNetworkingType :: (MonadReader env m, HasPierConfig env) => m NetworkingType
|
|
|
|
getNetworkingType = do
|
|
|
|
PierConfig{..} <- view pierConfigL
|
|
|
|
pure pcNetworking
|
2019-10-18 01:32:06 +03:00
|
|
|
|
|
|
|
getAmesPort :: (MonadReader env m, HasPierConfig env) => m (Maybe Word16)
|
|
|
|
getAmesPort = do
|
|
|
|
PierConfig{..} <- view pierConfigL
|
|
|
|
pure pcAmesPort
|