Parse client command line options

This commit is contained in:
Joscha 2020-02-10 23:07:55 +00:00
parent fc35f3bf64
commit 9f5d1c5684
2 changed files with 45 additions and 0 deletions

View file

@ -18,6 +18,7 @@ dependencies:
- async
- brick
- containers
- optparse-applicative
- text
- text-zipper
- transformers

View file

@ -0,0 +1,44 @@
module Forest.Client.Options
( ClientOptions(..)
, clientOptionsParserInfo
) where
import Options.Applicative
data ClientOptions = ClientOptions
{ clientHostName :: String
, clientPort :: Int
, clientPath :: String
, clientSsl :: Bool
}
parser :: Parser ClientOptions
parser = ClientOptions
<$> strArgument
( help "The name of the host to connect to"
<> metavar "HOST"
)
<*> option auto
( short 'p'
<> long "port"
<> help "The port to connect to"
<> value 11133 -- Chosen by fair dice roll
<> showDefault
<> metavar "PORT"
)
<*> strOption
( short 'P'
<> long "path"
<> help "The path to connect to on the given domain"
<> value ""
<> showDefault
<> metavar "PATH"
)
<*> flag True False -- Ssl enabled by default
( short 'n'
<> long "no-ssl"
<> help "This flag disables ssl on outgoing websocket connections"
)
clientOptionsParserInfo :: ParserInfo ClientOptions
clientOptionsParserInfo = info parser mempty