{-# LANGUAGE Safe #-}
module Text.LambdaOptions.Example.Example_2_Constructors (
main,
) where
import qualified System.Environment as Env
import qualified Text.LambdaOptions as L
data Option
= Foo Int String
| Bar [Double]
| Baz
deriving Show
options :: L.Options Option
options = do
L.addOption
(L.kw "--foo"
`L.argText` "INT STR"
`L.text` "Do Foo.")
$ Foo
L.addOption
(L.kw "--bar"
`L.argText` "NUMS*"
`L.text` "Do Bar.")
$ Bar . L.unList
L.addOption
(L.kw "--baz"
`L.text` "Do Baz.")
$ Baz
main :: IO ()
main = do
args <- Env.getArgs
case L.runOptions options args of
Left e -> do
putStrLn $ L.prettyOptionsError e
putStrLn $ L.getHelpDescription options
Right opts -> print opts