aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ()