aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-02-11 10:32:17 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-02-11 10:32:17 +0300
commitf88cbf20be4007ed7174c292dc1b57cc9495aaa2 (patch)
tree03e40d11af1bef92f7b631564b607f62cfba4cff
parent3c383868f185db0009924ef55f6e1897bfb2ed47 (diff)
downloadsuem-f88cbf20be4007ed7174c292dc1b57cc9495aaa2.tar
suem-f88cbf20be4007ed7174c292dc1b57cc9495aaa2.tar.xz
suem-f88cbf20be4007ed7174c292dc1b57cc9495aaa2.zip
Config completed.
-rw-r--r--Main.hs17
-rw-r--r--src/Suem.hs18
2 files changed, 31 insertions, 4 deletions
diff --git a/Main.hs b/Main.hs
index bc5032e..caaa8b8 100644
--- a/Main.hs
+++ b/Main.hs
@@ -3,6 +3,21 @@ module Main where
import Options.Applicative
import Suem
+inet_socket :: String -> Parser ConfigSocket
+inet_socket sock = ConfigInet <$> strOption
+ ( long ("i" ++ sock)
+ <> metavar ("ADDR_" ++ sock)
+ <> help ("Address for internet socket " ++ sock) )
+
+unix_socket :: String -> Parser ConfigSocket
+unix_socket sock = ConfigUnix <$> strOption
+ ( long ("u" ++ sock)
+ <> metavar ("ADDR_" ++ sock)
+ <> help ("Address for UNIX socket " ++ sock) )
+
+socket :: String -> Parser (Maybe ConfigSocket)
+socket sock = optional (inet_socket sock <|> unix_socket sock)
+
config :: Parser Config
config = Config
<$> option auto
@@ -26,6 +41,8 @@ config = Config
<> showDefault
<> value "rom.bin"
<> help "Path to file to load into ROM" )
+ <*> socket "0" <*> socket "1" <*> socket "2" <*> socket "3"
+ <*> socket "4" <*> socket "5" <*> socket "6" <*> socket "7"
main :: IO ()
main = suem =<< execParser opts
diff --git a/src/Suem.hs b/src/Suem.hs
index bbdfa78..a6df56f 100644
--- a/src/Suem.hs
+++ b/src/Suem.hs
@@ -1,11 +1,21 @@
-module Suem (Config(..), suem) where
+module Suem (Config(..), ConfigSocket(..), suem) where
+
+data ConfigSocket = ConfigInet String | ConfigUnix String
data Config = Config {
freq :: Int,
ram :: Int,
- rom :: String
+ rom :: String,
+ s0 :: Maybe ConfigSocket,
+ s1 :: Maybe ConfigSocket,
+ s2 :: Maybe ConfigSocket,
+ s3 :: Maybe ConfigSocket,
+ s4 :: Maybe ConfigSocket,
+ s5 :: Maybe ConfigSocket,
+ s6 :: Maybe ConfigSocket,
+ s7 :: Maybe ConfigSocket
}
suem :: Config -> IO ()
-suem (Config _ _ r) = putStrLn $ "Loaded " ++ r ++ " into ROM."
-suem _ = return ()
+suem (Config _ _ r _ _ _ _ _ _ _ _) = putStrLn $ "Loaded " ++ r ++ " into ROM."
+suem _ = return ()