{-# LANGUAGE OverloadedStrings #-} module Network.ZRE.Options ( parseOptions ) where import Options.Applicative import Data.Semigroup ((<>)) import qualified Data.ByteString.Char8 as B import Network.ZRE.Types import System.ZMQ4.Endpoint parseOptions :: Parser ZRECfg parseOptions :: Parser ZRECfg parseOptions = ByteString -> Int -> Int -> Int -> [ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg ZRECfg (ByteString -> Int -> Int -> Int -> [ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) -> Parser ByteString -> Parser (Int -> Int -> Int -> [ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (String -> ByteString B.pack (String -> ByteString) -> Parser String -> Parser ByteString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Mod OptionFields String -> Parser String forall s. IsString s => Mod OptionFields s -> Parser s strOption (String -> Mod OptionFields String forall (f :: * -> *) a. HasName f => String -> Mod f a long "name" Mod OptionFields String -> Mod OptionFields String -> Mod OptionFields String forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields String forall (f :: * -> *) a. HasName f => Char -> Mod f a short 'n' Mod OptionFields String -> Mod OptionFields String -> Mod OptionFields String forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields String forall (f :: * -> *) a. HasValue f => a -> Mod f a value "" Mod OptionFields String -> Mod OptionFields String -> Mod OptionFields String forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields String forall (f :: * -> *) a. String -> Mod f a help "Node name")) Parser (Int -> Int -> Int -> [ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) -> Parser Int -> Parser (Int -> Int -> [ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> (Int -> Int forall a. Num a => a -> a isec (Int -> Int) -> Parser Int -> Parser Int forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> ReadM Int -> Mod OptionFields Int -> Parser Int forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM Int forall a. Read a => ReadM a auto (String -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => String -> Mod f a long "quiet-period" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => Char -> Mod f a short 'q' Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar "N" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Int -> Mod OptionFields Int forall (f :: * -> *) a. HasValue f => a -> Mod f a value (Float -> Int forall a. RealFrac a => a -> Int sec (1.0 :: Float)) Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. String -> Mod f a help "Ping peer after N seconds")) Parser (Int -> Int -> [ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) -> Parser Int -> Parser (Int -> [ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ((Int -> Int -> Int forall a. Num a => a -> a -> a *100000) (Int -> Int) -> Parser Int -> Parser Int forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> ReadM Int -> Mod OptionFields Int -> Parser Int forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM Int forall a. Read a => ReadM a auto (String -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => String -> Mod f a long "dead-period" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => Char -> Mod f a short 'd' Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar "N" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Int -> Mod OptionFields Int forall (f :: * -> *) a. HasValue f => a -> Mod f a value (Float -> Int forall a. RealFrac a => a -> Int sec (1.0 :: Float)) Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. String -> Mod f a help "Mark peer dead after N seconds")) Parser (Int -> [ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) -> Parser Int -> Parser ([ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ((Int -> Int -> Int forall a. Num a => a -> a -> a *100000) (Int -> Int) -> Parser Int -> Parser Int forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> ReadM Int -> Mod OptionFields Int -> Parser Int forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM Int forall a. Read a => ReadM a auto (String -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => String -> Mod f a long "beacon-period" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => Char -> Mod f a short 'b' Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar "N" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Int -> Mod OptionFields Int forall (f :: * -> *) a. HasValue f => a -> Mod f a value (Float -> Int forall a. RealFrac a => a -> Int sec (0.9 :: Float)) Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. String -> Mod f a help "Send beacon every N seconds")) Parser ([ByteString] -> Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) -> Parser [ByteString] -> Parser (Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> (((String -> ByteString) -> [String] -> [ByteString] forall a b. (a -> b) -> [a] -> [b] map String -> ByteString B.pack) ([String] -> [ByteString]) -> Parser [String] -> Parser [ByteString] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser String -> Parser [String] forall (f :: * -> *) a. Alternative f => f a -> f [a] many (Mod OptionFields String -> Parser String forall s. IsString s => Mod OptionFields s -> Parser s strOption (String -> Mod OptionFields String forall (f :: * -> *) a. HasName f => String -> Mod f a long "iface" Mod OptionFields String -> Mod OptionFields String -> Mod OptionFields String forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields String forall (f :: * -> *) a. HasName f => Char -> Mod f a short 'i' Mod OptionFields String -> Mod OptionFields String -> Mod OptionFields String forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields String forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar "IFACE" Mod OptionFields String -> Mod OptionFields String -> Mod OptionFields String forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields String forall (f :: * -> *) a. String -> Mod f a help "Interfaces"))) Parser (Endpoint -> Maybe Endpoint -> Bool -> ZRECfg) -> Parser Endpoint -> Parser (Maybe Endpoint -> Bool -> ZRECfg) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ReadM Endpoint -> Mod OptionFields Endpoint -> Parser Endpoint forall a. ReadM a -> Mod OptionFields a -> Parser a option ((ByteString -> Either String Endpoint) -> ReadM Endpoint forall a. (ByteString -> Either String a) -> ReadM a attoReadM ByteString -> Either String Endpoint parseAttoUDPEndpoint) (String -> Mod OptionFields Endpoint forall (f :: * -> *) a. HasName f => String -> Mod f a long "mcast" Mod OptionFields Endpoint -> Mod OptionFields Endpoint -> Mod OptionFields Endpoint forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields Endpoint forall (f :: * -> *) a. HasName f => Char -> Mod f a short 'm' Mod OptionFields Endpoint -> Mod OptionFields Endpoint -> Mod OptionFields Endpoint forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Endpoint forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar "IP:PORT" Mod OptionFields Endpoint -> Mod OptionFields Endpoint -> Mod OptionFields Endpoint forall a. Semigroup a => a -> a -> a <> Endpoint -> Mod OptionFields Endpoint forall (f :: * -> *) a. HasValue f => a -> Mod f a value Endpoint defMCastEndpoint Mod OptionFields Endpoint -> Mod OptionFields Endpoint -> Mod OptionFields Endpoint forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Endpoint forall (f :: * -> *) a. String -> Mod f a help "IP:PORT of the multicast group") Parser (Maybe Endpoint -> Bool -> ZRECfg) -> Parser (Maybe Endpoint) -> Parser (Bool -> ZRECfg) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser Endpoint -> Parser (Maybe Endpoint) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional (ReadM Endpoint -> Mod OptionFields Endpoint -> Parser Endpoint forall a. ReadM a -> Mod OptionFields a -> Parser a option ((ByteString -> Either String Endpoint) -> ReadM Endpoint forall a. (ByteString -> Either String a) -> ReadM a attoReadM ByteString -> Either String Endpoint parseAttoTCPEndpoint) (String -> Mod OptionFields Endpoint forall (f :: * -> *) a. HasName f => String -> Mod f a long "gossip" Mod OptionFields Endpoint -> Mod OptionFields Endpoint -> Mod OptionFields Endpoint forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields Endpoint forall (f :: * -> *) a. HasName f => Char -> Mod f a short 'g' Mod OptionFields Endpoint -> Mod OptionFields Endpoint -> Mod OptionFields Endpoint forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Endpoint forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar "IP:PORT" Mod OptionFields Endpoint -> Mod OptionFields Endpoint -> Mod OptionFields Endpoint forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Endpoint forall (f :: * -> *) a. String -> Mod f a help "IP:PORT of the gossip server")) Parser (Bool -> ZRECfg) -> Parser Bool -> Parser ZRECfg forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> (Bool -> Mod FlagFields Bool -> Parser Bool forall a. a -> Mod FlagFields a -> Parser a flag' Bool False (String -> Mod FlagFields Bool forall (f :: * -> *) a. HasName f => String -> Mod f a long "debug" Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool forall a. Semigroup a => a -> a -> a <> Char -> Mod FlagFields Bool forall (f :: * -> *) a. HasName f => Char -> Mod f a short 'd')) attoReadM :: (B.ByteString -> Either String a) -> ReadM a attoReadM :: (ByteString -> Either String a) -> ReadM a attoReadM p :: ByteString -> Either String a p = (String -> Either String a) -> ReadM a forall a. (String -> Either String a) -> ReadM a eitherReader (ByteString -> Either String a p (ByteString -> Either String a) -> (String -> ByteString) -> String -> Either String a forall b c a. (b -> c) -> (a -> b) -> a -> c . String -> ByteString B.pack)