summaryrefslogtreecommitdiff
path: root/fig-bus/main/Main.hs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-05-06 03:45:51 -0400
committerLLLL Colonq <llll@colonq>2025-05-06 03:45:51 -0400
commitf010327cd1b9fd3b260ef1623d252723f395fbc7 (patch)
treee1d88e671d6e909e3986342807a71e55a86df6a8 /fig-bus/main/Main.hs
parent2bac23772ea3b8e95e27bcd4f8d9c4d91538f840 (diff)
Binary message bus
Diffstat (limited to 'fig-bus/main/Main.hs')
-rw-r--r--fig-bus/main/Main.hs23
1 files changed, 17 insertions, 6 deletions
diff --git a/fig-bus/main/Main.hs b/fig-bus/main/Main.hs
index dcafffd..bf5c170 100644
--- a/fig-bus/main/Main.hs
+++ b/fig-bus/main/Main.hs
@@ -4,18 +4,28 @@ import Fig.Prelude
import Options.Applicative
-import qualified Fig.Bus
-import qualified Fig.Bus.Binary
+import qualified Fig.Bus.SExp as SExp
+import qualified Fig.Bus.Binary as Binary
+
+data Command = SExp | Binary
+
+parseCommand :: Parser Command
+parseCommand = subparser $ mconcat
+ [ command "sexp" $ info (pure SExp) (progDesc "Launch the s-expression bus")
+ , command "binary" $ info (pure Binary) (progDesc "Launch the binary bus")
+ ]
data Opts = Opts
- { host :: Text
- , port :: Text
+ { host :: !Text
+ , port :: !Text
+ , cmd :: !Command
}
parseOpts :: Parser Opts
parseOpts = Opts
<$> strOption (long "host" <> metavar "HOST" <> help "Interface to bind" <> value "localhost")
<*> strOption (long "port" <> metavar "PORT" <> help "Port to bind" <> showDefault <> value "32050")
+ <*> parseCommand
main :: IO ()
main = do
@@ -23,5 +33,6 @@ main = do
( fullDesc
<> header "fig-bus - a pub/sub message bus"
)
- -- Fig.Bus.main (Just opts.host, opts.port)
- Fig.Bus.Binary.main (Just opts.host, opts.port)
+ case opts.cmd of
+ SExp -> SExp.main (Just opts.host, opts.port)
+ Binary -> Binary.main (Just opts.host, opts.port)