From 9a698e0c32bc413bce575bfd9aaeaa5364afc403 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 23 May 2017 20:02:26 +0200 Subject: Config -> Kirk.Config --- Config.hs | 61 ---------------------------------------------------------- Kirk/Config.hs | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ircout.hs | 2 +- 3 files changed, 62 insertions(+), 62 deletions(-) delete mode 100644 Config.hs create mode 100644 Kirk/Config.hs diff --git a/Config.hs b/Config.hs deleted file mode 100644 index fc959e1..0000000 --- a/Config.hs +++ /dev/null @@ -1,61 +0,0 @@ -{-# LANGUAGE ApplicativeDo #-} -{-# LANGUAGE RecordWildCards #-} - -module Config - ( Config(..) - , parseConfigFromArgs - ) - where - -import Data.Monoid -import Network.Socket (HostName,PortNumber) -import Options.Applicative - - -data Config = Config - { nick :: String - , msgtarget :: [String] - , server_hostname :: HostName - , server_port :: PortNumber - } - - -config :: Parser Config -config = do - nick <- strOption - ( long "nick" - <> value "ircout" - <> metavar "NICK" ) - - server_hostname <- strOption - ( long "host" - <> value "ni.r" - <> metavar "HOST" ) - - server_port <- option auto - ( long "port" - <> value 6667 - <> metavar "PORT") - - msgtarget <- some (argument str - ( metavar "TARGET..." - <> help - "List of channels and nicks. \ - \Ircout will join all channels. \ - \Users get messaged directly" - )) - - pure Config{..} - - -pinfo :: ParserInfo Config -pinfo = - info (config <**> helper) - ( fullDesc - <> progDesc "Read lines from stdin and forward them to IRC." - <> header "ircout - forward stdin to IRC" - ) - - -parseConfigFromArgs :: IO Config -parseConfigFromArgs = execParser pinfo diff --git a/Kirk/Config.hs b/Kirk/Config.hs new file mode 100644 index 0000000..d123aab --- /dev/null +++ b/Kirk/Config.hs @@ -0,0 +1,61 @@ +{-# LANGUAGE ApplicativeDo #-} +{-# LANGUAGE RecordWildCards #-} + +module Kirk.Config + ( Config(..) + , parseConfigFromArgs + ) + where + +import Data.Monoid +import Network.Socket (HostName,PortNumber) +import Options.Applicative + + +data Config = Config + { nick :: String + , msgtarget :: [String] + , server_hostname :: HostName + , server_port :: PortNumber + } + + +config :: Parser Config +config = do + nick <- strOption + ( long "nick" + <> value "ircout" + <> metavar "NICK" ) + + server_hostname <- strOption + ( long "host" + <> value "ni.r" + <> metavar "HOST" ) + + server_port <- option auto + ( long "port" + <> value 6667 + <> metavar "PORT") + + msgtarget <- some (argument str + ( metavar "TARGET..." + <> help + "List of channels and nicks. \ + \Ircout will join all channels. \ + \Users get messaged directly" + )) + + pure Config{..} + + +pinfo :: ParserInfo Config +pinfo = + info (config <**> helper) + ( fullDesc + <> progDesc "Read lines from stdin and forward them to IRC." + <> header "ircout - forward stdin to IRC" + ) + + +parseConfigFromArgs :: IO Config +parseConfigFromArgs = execParser pinfo diff --git a/ircout.hs b/ircout.hs index e3d0296..3edf388 100644 --- a/ircout.hs +++ b/ircout.hs @@ -10,7 +10,7 @@ import Network (withSocketsDo,PortID(..),connectTo) import qualified Data.ByteString.Char8 as BS8 import System.IO (hSetBuffering,hSetNewlineMode,hPutStrLn,hClose,hGetLine,BufferMode(LineBuffering),universalNewlineMode,Handle) -import Config +import Kirk.Config main :: IO () -- cgit v1.2.3