urbit/pkg/hs/urbit-king/lib/Urbit/King/Config.hs

62 lines
1.3 KiB
Haskell
Raw Normal View History

2020-01-23 07:16:09 +03:00
{-|
2020-05-22 21:12:28 +03:00
Pier Configuration
2020-01-23 07:16:09 +03:00
-}
module Urbit.King.Config where
import Urbit.Prelude
import qualified Urbit.Vere.Serf as Serf
2020-01-23 07:16:09 +03:00
{-|
2020-05-22 21:12:28 +03:00
All the configuration data revolving around a ship and the current
execution options.
-}
data PierConfig = PierConfig
{ _pcPierPath :: FilePath
, _pcDryRun :: Bool
, _pcSerfExe :: Maybe Text
, _pcSerfFlags :: [Serf.Flag]
2020-05-22 21:12:28 +03:00
} deriving (Show)
makeLenses ''PierConfig
2020-05-22 21:12:28 +03:00
class HasPierPath a where
pierPathL :: Lens' a FilePath
class HasDryRun a where
dryRunL :: Lens' a Bool
class (HasPierPath a, HasDryRun a) => HasPierConfig a where
pierConfigL :: Lens' a PierConfig
instance HasPierPath PierConfig where
pierPathL = pcPierPath
2020-05-22 21:12:28 +03:00
instance HasDryRun PierConfig where
dryRunL = pcDryRun
-------------------------------------------------------------------------------
data NetMode
= NMNone
| NMLocalhost
| NMNormal
deriving (Eq, Ord, Show)
data NetworkConfig = NetworkConfig
{ _ncNetMode :: NetMode
, _ncAmesPort :: Maybe Word16
, _ncNoAmes :: Bool
, _ncNoHttp :: Bool
, _ncNoHttps :: Bool
, _ncHttpPort :: Maybe Word16
, _ncHttpsPort :: Maybe Word16
, _ncLocalPort :: Maybe Word16
} deriving (Show)
makeLenses ''NetworkConfig
class HasNetworkConfig env where
networkConfigL :: Lens' env NetworkConfig