data TLSMode = NoTLS | TLS {tlsCertPath :: FilePath, tlsKeyPath :: FilePath, tlsPort :: Warp.Port} tlsModeArgs :: OA.Parser TLSMode tlsModeArgs = noTLS <|> (TLS <$> tlsCertPath <*> tlsKeyPath <*> tlsPort) where noTLS = OA.flag' NoTLS (OA.long "no-tls") tlsPort = OA.option OA.auto (OA.long "tls-port" <> OA.value 443 <> OA.showDefault) tlsCertPath = OA.option OA.str (OA.long "tls-cert-path" <> OA.metavar "TLS_CERT_PATH") tlsKeyPath = OA.option OA.str (OA.long "tls-key-path" <> OA.metavar "TLS_KEY_PATH") data Command = Serve {logPath :: FilePath, contentPath :: FilePath, httpPort :: Warp.Port, tlsMode :: TLSMode} command :: OA.Parser Command command = serveCmd where serverSwitch = OA.flag' () (OA.long "server" <> OA.short 's') logPath = OA.option OA.str (OA.long "log-path" <> OA.short 'l' <> OA.metavar "LOG_PATH") contentPath = OA.option OA.str (OA.long "content-path" <> OA.short 'c' <> OA.metavar "CONTENT_PATH") httpPort = OA.option OA.auto (OA.long "http-port" <> OA.value 80 <> OA.showDefault) serveCmd = serverSwitch *> (Serve <$> logPath <*> contentPath <*> httpPort <*> tlsModeArgs)
secret
Create a paste
about