From f95d9bbde51ee26468177b2d34c669d9689fbea4 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Fri, 30 May 2025 02:55:35 -0400 Subject: web: Big refactor part 2 --- fig-web/main/Main.hs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'fig-web/main/Main.hs') diff --git a/fig-web/main/Main.hs b/fig-web/main/Main.hs index 8db47e2..89ac345 100644 --- a/fig-web/main/Main.hs +++ b/fig-web/main/Main.hs @@ -6,18 +6,28 @@ import Fig.Prelude import Options.Applicative +import Fig.Web.Types import Fig.Web.Utils import qualified Fig.Web.Public as Public import qualified Fig.Web.Secure as Secure +parsePublicOptions :: Parser PublicOptions +parsePublicOptions = do + pure PublicOptions{} + +parseSecureOptions :: Parser SecureOptions +parseSecureOptions = do + simAuth <- switch (long "sim-auth" <> help "Simulate authentication instead of actually requiring authentication proxy headers") + pure SecureOptions{..} + data Command - = Public - | Secure + = Public PublicOptions + | Secure SecureOptions parseCommand :: Parser Command parseCommand = subparser $ mconcat - [ command "public" $ info (pure Public) (progDesc "Launch the public web server") - , command "secure" $ info (pure Secure) (progDesc "Launch the private web server (intended to be run behind authentication proxy)") + [ command "public" $ info (Public <$> parsePublicOptions) (progDesc "Launch the public web server") + , command "secure" $ info (Secure <$> parseSecureOptions) (progDesc "Launch the private web server (intended to be run behind authentication proxy)") ] data Opts = Opts @@ -43,5 +53,5 @@ main = do ) cfg <- loadConfig opts.config case opts.cmd of - Public -> Public.server cfg (opts.busHost, opts.busPort) - Secure -> Secure.server cfg (opts.busHost, opts.busPort) + Public o -> Public.server o cfg (opts.busHost, opts.busPort) + Secure o -> Secure.server o cfg (opts.busHost, opts.busPort) -- cgit v1.2.3