mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Pull port and host from environment
This commit is contained in:
parent
170cadfcbd
commit
19f30f33cc
@ -153,6 +153,7 @@ library
|
||||
, Semantic.CLI
|
||||
, Semantic.Diff
|
||||
, Semantic.Distribute
|
||||
, Semantic.Env
|
||||
, Semantic.Graph
|
||||
, Semantic.IO
|
||||
, Semantic.Log
|
||||
|
15
src/Semantic/Env.hs
Normal file
15
src/Semantic/Env.hs
Normal file
@ -0,0 +1,15 @@
|
||||
module Semantic.Env where
|
||||
|
||||
import Control.Monad.IO.Class
|
||||
import Prologue
|
||||
import System.Environment
|
||||
import Text.Read (readMaybe)
|
||||
|
||||
envLookupHost :: MonadIO io => String -> String -> io String
|
||||
envLookupHost defaultHost k = liftIO $ fromMaybe defaultHost <$> lookupEnv k
|
||||
|
||||
envLookupPort :: MonadIO io => Int -> String -> io Int
|
||||
envLookupPort defaultPort k = liftIO $ parsePort <$> lookupEnv k
|
||||
where parsePort x | Just s <- x
|
||||
, Just p <- readMaybe s = p
|
||||
| otherwise = defaultPort
|
Loading…
Reference in New Issue
Block a user