From f010327cd1b9fd3b260ef1623d252723f395fbc7 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 6 May 2025 03:45:51 -0400 Subject: Binary message bus --- fig-bus/main/Main.hs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'fig-bus/main') 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) -- cgit v1.2.3