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
|
|
|
-}
|
2020-01-24 08:28:38 +03:00
|
|
|
module Urbit.King.Config where
|
2019-10-22 21:25:04 +03:00
|
|
|
|
2020-01-24 08:28:38 +03:00
|
|
|
import Urbit.Prelude
|
2019-10-22 21:25:04 +03:00
|
|
|
|
2020-06-11 02:41:09 +03:00
|
|
|
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.
|
2019-12-17 17:31:50 +03:00
|
|
|
-}
|
2019-10-22 21:25:04 +03:00
|
|
|
data PierConfig = PierConfig
|
2020-06-11 02:41:09 +03:00
|
|
|
{ _pcPierPath :: FilePath
|
|
|
|
, _pcDryRun :: Bool
|
2020-07-25 02:29:39 +03:00
|
|
|
, _pcSerfExe :: Maybe Text
|
2020-06-11 02:41:09 +03:00
|
|
|
, _pcSerfFlags :: [Serf.Flag]
|
2020-05-22 21:12:28 +03:00
|
|
|
} deriving (Show)
|
2019-12-17 17:31:50 +03:00
|
|
|
|
|
|
|
makeLenses ''PierConfig
|
2019-10-22 21:25:04 +03:00
|
|
|
|
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
|
2019-10-22 21:25:04 +03:00
|
|
|
|
2020-05-22 21:12:28 +03:00
|
|
|
instance HasDryRun PierConfig where
|
|
|
|
dryRunL = pcDryRun
|
2019-10-22 21:25:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
2020-03-03 02:24:28 +03:00
|
|
|
data NetMode
|
|
|
|
= NMNone
|
|
|
|
| NMLocalhost
|
|
|
|
| NMNormal
|
|
|
|
deriving (Eq, Ord, Show)
|
2019-10-22 21:25:04 +03:00
|
|
|
|
|
|
|
data NetworkConfig = NetworkConfig
|
2020-03-03 02:24:28 +03:00
|
|
|
{ _ncNetMode :: NetMode
|
|
|
|
, _ncAmesPort :: Maybe Word16
|
2020-05-13 02:55:49 +03:00
|
|
|
, _ncNoAmes :: Bool
|
|
|
|
, _ncNoHttp :: Bool
|
|
|
|
, _ncNoHttps :: Bool
|
2020-03-03 02:24:28 +03:00
|
|
|
, _ncHttpPort :: Maybe Word16
|
|
|
|
, _ncHttpsPort :: Maybe Word16
|
|
|
|
, _ncLocalPort :: Maybe Word16
|
2019-10-22 21:25:04 +03:00
|
|
|
} deriving (Show)
|
|
|
|
|
2020-03-03 02:24:28 +03:00
|
|
|
makeLenses ''NetworkConfig
|
|
|
|
|
2019-10-22 21:25:04 +03:00
|
|
|
class HasNetworkConfig env where
|
|
|
|
networkConfigL :: Lens' env NetworkConfig
|