module FeedGipeda.Types where
import Data.Time (NominalDiffTime)
data Paths
= Paths
{ configFile :: FilePath
, gipeda :: FilePath
} deriving (Show, Eq)
data Endpoint
= Endpoint
{ host :: String
, port :: Int
} deriving (Show, Eq)
type Timeout
= NominalDiffTime
data Command
= Check
| Build BuildMode Timeout
deriving (Show, Eq)
data BuildMode
= Once
| WatchForChanges NominalDiffTime
deriving (Show, Eq)
data Deployment
= NoDeployment
| Deploy String
deriving (Show, Eq)
data ProcessRole
= Master Int
| Slave Int Endpoint
| Both Int Int
deriving (Show, Eq)
masterEndpoint :: ProcessRole -> Endpoint
masterEndpoint (Master port) = Endpoint "127.0.0.1" port
masterEndpoint (Both masterPort _) = Endpoint "127.0.0.1" masterPort
masterEndpoint (Slave _ ep) = ep
slaveEndpoint :: ProcessRole -> Maybe Endpoint
slaveEndpoint (Slave port _) = Just (Endpoint "127.0.0.1" port)
slaveEndpoint (Both _ slavePort) = Just (Endpoint "127.0.0.1" slavePort)
slaveEndpoint _ = Nothing
isBoth :: ProcessRole -> Bool
isBoth (Both _ _) = True
isBoth _ = False
data Verbosity
= Verbose
| NotVerbose
deriving (Show, Eq)