Parse client command line options
This commit is contained in:
parent
fc35f3bf64
commit
9f5d1c5684
2 changed files with 45 additions and 0 deletions
44
src/Forest/Client/Options.hs
Normal file
44
src/Forest/Client/Options.hs
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue