mirror of
https://github.com/urbit/shrub.git
synced 2024-12-21 01:41:37 +03:00
54 lines
1.2 KiB
Haskell
54 lines
1.2 KiB
Haskell
{-|
|
|
Pier Configuration
|
|
-}
|
|
module Ur.King.Config where
|
|
|
|
import Ur.Prelude
|
|
|
|
{-|
|
|
All the configuration data revolving around a ship and the current
|
|
execution options.
|
|
-}
|
|
data PierConfig = PierConfig
|
|
{ _pcPierPath :: FilePath
|
|
, _pcDryRun :: Bool
|
|
} deriving (Show)
|
|
|
|
makeLenses ''PierConfig
|
|
|
|
class HasPierConfig env where
|
|
pierConfigL :: Lens' env PierConfig
|
|
|
|
pierPathL ∷ HasPierConfig a => Lens' a FilePath
|
|
pierPathL = pierConfigL . pcPierPath
|
|
|
|
dryRunL :: HasPierConfig a => Lens' a Bool
|
|
dryRunL = pierConfigL . pcDryRun
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
data NetworkingType
|
|
= NetworkNone
|
|
| NetworkNormal
|
|
| NetworkLocalhost
|
|
deriving (Show)
|
|
|
|
data NetworkConfig = NetworkConfig
|
|
{ ncNetworking :: NetworkingType
|
|
, ncAmesPort :: Maybe Word16
|
|
} deriving (Show)
|
|
|
|
class HasNetworkConfig env where
|
|
networkConfigL :: Lens' env NetworkConfig
|
|
|
|
getNetworkingType :: (MonadReader env m, HasNetworkConfig env)
|
|
=> m NetworkingType
|
|
getNetworkingType = do
|
|
NetworkConfig{..} <- view networkConfigL
|
|
pure ncNetworking
|
|
|
|
getAmesPort :: (MonadReader env m, HasNetworkConfig env) => m (Maybe Word16)
|
|
getAmesPort = do
|
|
NetworkConfig{..} <- view networkConfigL
|
|
pure ncAmesPort
|